Skip to content
Tcl Source Code View Ticket
Login

View Ticket

foreach memleak

Closed / Fixed80304238ac5310b259c79c546d36d790c2a1d39eCreated 11 years agoUpdated 11 years ago
Descriptionplain2016-02-25 20:18:21
This script leaks 48 bytes:

proc doit script {
    eval $script
    set index xx
}
doit {foreach index foo {}}

This leak is what prevents me getting
a clean valgrind of our release candidates
because my system has an install of "nsf 2.0.0"
and it has code like this in its
pkgIndex.tcl file.  This solves the mystery of
why others see clean valgrind runs and I do not.
Referenced by2
dgpplain2016-02-26 04:10:37
It appears that this code is a nasty way to create
a circular reference, where each of 2 Tcl_Obj values
holds a reference to the other as part of its intrep.
This defeats the refCounting system, and the
objects leak.

The cross referencing comes between a "list"
value with a single element which is a "localVarName"
value with a cached localName (twoPtrValue.ptr1)
which is the original list value.
dgpplain2016-02-26 15:44:22
See bug-80304238ac branch for candidate fix.
dgpplain2016-03-01 16:56:18
Fix merged to trunk.

Same demo script does not leak in 8.5.19.

Either no leak there, or no reliabale way to
demo it (yet). Either way, doing nothing on
8.5 branch.
Log in (anonymous is fine) to add a comment.