Skip to content
Tcl Source Code View Ticket
Login

View Ticket

[ledit] corrupts string literal value

Closed / Fixeda366c6efee1f70cc9b27f949d41afe3ee77c0f08Created 3 years agoUpdated 3 years ago
Descriptionplain2023-07-14 14:59:26
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.
Referenced by2
dgp Ticket [a366c6efee]: 3 changes [History diff]2023-07-14 15:01:13
jan.nijtmanswiki2023-07-14 15:15:38

This smells like the TclDuplicatePureObj() danger somewhere.

apnadkarniplain2023-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.
apnadkarniplain2023-07-15 04:40:36
Found the issue, as always not where I suspected. Fix forthcoming.
apnadkarniplain2023-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.
Log in (anonymous is fine) to add a comment.