Tcl Source Code

View Ticket
Login
Ticket UUID: a366c6efee1f70cc9b27f949d41afe3ee77c0f08
Title: [ledit] corrupts string literal value
Type: Bug Created on: 2023-07-14 14:59:26
Submitter: dgp Assigned to: apnadkarni
Subsystem: - New Builtin Commands Severity: Severe
Priority: 5 Medium Last modified: 2023-07-16 07:27:34
Status: Closed Closed by: apnadkarni
Resolution: Fixed Closed on: 2023-07-16 07:27:34
Version: trunk
Description:
The tests ledit-4.2 and socket_inet-13.1 interact and cause failure.
The interaction can be summarized by this demo script:

% proc demo {} {
set l { }
puts [list [ledit l 1 1] $l]
set result foo
append result " " bar
}
% demo
{} {}
foobar

The result "foobar" is wrong.  It should be "foo bar".
It appears that the string literal " " has had its string value
transformed to "" before the append.  This might be the result
of not managing value-sharing properly when the [ledit] command
changes the value of $l from { } to {}.

Hope that's enough to lead the [ledit] keepers to a fix.
User Comments:
jan.nijtmans added on 2023-07-14 15:15:38:

This smells like the TclDuplicatePureObj() danger somewhere.


apnadkarni added on 2023-07-15 04:06:30:
Will take a look later today. Strangely enough, 8.7 which pretty much shares the ledit code does not seem to have this problem. Not that means much...

Thanks Don for a very concise demo.

apnadkarni added on 2023-07-15 04:40:36:
Found the issue, as always not where I suspected. Fix forthcoming.

apnadkarni added on 2023-07-16 07:27:34:
Fixed in [fe628d36ce].

As to why it did not manifest in 8.7 is that the more sophisticated  TclCheckEmptyString check in 9.0 triggered the bug.