Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2007-09-09
06:38 • Closed ticket [1710710fff]: Memory leaks in unload.test plus 7 other changes artifact: 09f8c20559 user: msofer
2007-05-11
01:50 • Ticket [1710710fff]: 5 changes artifact: 368503fefa user: dgp
2007-05-03
04:04 • Ticket [1710710fff]: 6 changes artifact: b20c68f0cc user: kennykb
2007-05-02
07:32 • Ticket [1710710fff]: 4 changes artifact: 3d7237fd72 user: msofer
06:03 • Ticket [1710710fff]: 4 changes artifact: 83cd83835e user: mistachkin
05:45 • Ticket [1710710fff]: 4 changes artifact: cb01cfdc32 user: mistachkin
00:00 • Ticket [1710710fff]: 4 changes artifact: e9e5f1bcf7 user: kennykb
00:00 • Add attachment leakunload.txt to ticket [1710710fff] artifact: 14c73e77f2 user: kennykb
2007-05-01
17:00 • New ticket [1710710fff] Memory leaks in unload.test. artifact: a302997196 user: kennykb

Memory leaks in unload.test

Closed / Fixed1710710fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 19 years ago
Descriptionplain2007-05-01 17:00:59
Running valgrind on the Tcl test suite reveals numerous
memory leaks in unload.test.  They appear to be the
loaded module failing to clean up after itself;
since programmers are likely to use its code as an
example of writing an unloadable module, it should
do a better job.

valgrind log is attached.
kennykbplain2007-05-02 00:00:59
File Added - 227376: leakunload.txt
mistachkinplain2007-05-02 05:45:59
Logged In: YES 
user_id=113501
Originator: NO


The pkgua library is leaking the interpTokenMap hash table itself (by not calling Tcl_DeleteHashTable in PkguaFreeTokensHashTable); however, the Tcl_SetVar leaks appear to be false alarms.  The memory being leaked is not owned by the package and the variables in question are not referred to by the package except to append values to them.
mistachkinplain2007-05-02 06:03:57
Logged In: YES 
user_id=113501
Originator: NO


There does not seem to be any other place in the core that uses Tcl_SetVar2 with TCL_APPEND_VALUE.  The only place I see using TCL_APPEND_VALUE is in tclExecute.c with TclPtrSetVar.  Perhaps the string object allocated by Tcl_SetVar2 is always leaked if TCL_APPEND_VALUE is used?
msoferplain2007-05-02 07:32:54
Logged In: YES 
user_id=148712
Originator: NO

There was indeed a refCount bug as mistachkin described; fix committed.
kennykbplain2007-05-03 04:04:22
Logged In: YES 
user_id=99768
Originator: YES

Verified that the leaks are plugged; leaving this open in case the maintainer wants to add tclTest.c code to exercise this path (without dltest, we'd never have seen it).
dgpplain2007-05-11 01:50:37
Logged In: YES 
user_id=80530
Originator: NO


I suspect this needs a backport
for 8.4.15 ?
msoferplain2007-09-09 06:38:07
Logged In: YES 
user_id=148712
Originator: NO

That was only a partial fix - TclPtrSetVar is a hairy monster wrt to the new value, and it remains one after this change. Tcl_SetVar2 needs to manage the refCount properly. 

Reverting the old fix, replacing with new fix in HEAD, 8.4 already correct.
Log in (anonymous is fine) to add a comment.

Attachments: