Skip to content
Tcl Source Code View Ticket
Login

View Ticket

ref count mismanagement in dict

Closed / Fixed876170ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 23 years ago
Descriptionplain2004-01-13 16:11:42
The attached file causes Tcl to crash with a
corrupted free object list.  I haven't had time
yet to try to distill it to an irreducible minimum,
but I observe that the program doesn't fail if
the empty dictionaries are created with
[dict create] instead of using the canonical
null object.
kennykbplain2004-01-13 23:11:42
File Added - 73274: uniqpfx.tcl
kennykb Ticket [876170ffff]: 1 change [History diff]2004-01-13 23:12:02
kennykbplain2004-01-13 23:45:06
File Added - 73286: trace
pspjuthplain2004-01-14 03:34:29
Logged In: YES 
user_id=98900

The bug is in tclDictObj.c line 596.
There is a Tcl_DuplicateObj that should
be followed by a Tcl_IncrRefCount.
pspjuthplain2004-01-14 04:19:31
Logged In: YES 
user_id=98900

Test case that triggers the bug if memdebug is on:

proc test {} {
    set successors [dict create x {c d}]
    dict set successors x a b
    dict get $successors x
}
test
dkfplain2004-01-14 16:38:33
File Added - 73390: dict.patch

Logged In: YES 
user_id=79902

I attach the patch Peter sent to me by email which fixes
this and which I applied to the core with a few minor mods.
 Thanks very much, Peter!
Log in (anonymous is fine) to add a comment.

Attachments: