Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2004-07-16
03:05 • Closed ticket [990552ffff]: TclFinalizeFilesystem leaks with TCL_THREADS plu... artifact: 9c58fcb374 user: vasiljevic
2004-07-14
21:56 • Ticket [990552ffff]: 4 changes artifact: 0428a72d4e user: vasiljevic
21:37 • Ticket [990552ffff]: 4 changes artifact: 90dd1b850e user: vincentdarley
21:37 • Ticket [990552ffff]: 1 change artifact: 98104cbe15 user: vincentdarley
2004-07-13
23:19 • New ticket [990552ffff]. artifact: 4fd750dc39 user: mistachkin

TclFinalizeFilesystem leaks with TCL_THREADS

Closed / Fixed990552ffffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 22 years ago
Descriptionplain2004-07-13 23:19:35
TclFinalizeFilesystem is being called after
Tcl_FinalizeThread from Tcl_Finalize.  When TCL_THREADS
is enabled, this causes a large leak because the thread
specific data allocated by TclFreeObj is never freed by
TclFinalizeThreadData (it has already been called by
Tcl_FinalizeThread).

Here is the valgrind output:

65751 bytes in 514 blocks are still reachable in loss
record 2 of 2
at 0x3C0250D5: malloc (in
/usr/local/lib/valgrind/vgpreload_memcheck.so)
by 0x3C04EE16: TclpAlloc (generic/tclAlloc.c:677)
by 0x3C0588F9: Tcl_DbCkalloc (generic/tclCkalloc.c:375)
by 0x3C0E9F7E: Tcl_GetThreadData (generic/tclThread.c:109)
by 0x3C0D1A81: TclFreeObj (generic/tclObj.c:770)
by 0x3C0D384D: Tcl_DbDecrRefCount (generic/tclObj.c:2777)
by 0x3C0BE978: TclFinalizeFilesystem
(generic/tclIOUtil.c:707)
by 0x3C08CF35: Tcl_Finalize (generic/tclEvent.c:910)
by 0x3C08CB98: Tcl_Exit (generic/tclEvent.c:638)
by 0x3C0C91CA: Tcl_Main (generic/tclMain.c:674)
by 0x8048637: main (unix/tclAppInit.c:90)
vincentdarley Ticket [990552ffff]: 1 change [History diff]2004-07-14 21:37:00
vincentdarleyplain2004-07-14 21:37:01
Logged In: YES 
user_id=32170

Hopefully Zoran will have some insights here...
vasiljevicplain2004-07-14 21:56:36
Logged In: YES 
user_id=95086

There has been quite a few issues with threads  
on application exit, that is when the master (main) 
therad exits. 
 
The interesting question is: does this happen also  
when a regular worker therad exits while the main 
thread is still alive? You can check this by compiling 
the test shell and use testthread command to create 
and destroy a worker thread. You can then observe  
the memory usage. Tell me what you get. 
 
I would normally scream already on such large holes 
and our app would normally not survive more than 
15 minutes operation if this is really true.
vasiljevicplain2004-07-16 03:05:57
Logged In: YES 
user_id=95086

Oh well, valgrind is right. There is indeed a leak there.
I have fixed this in the head branch by adding one 
TclFinalizeThreadData call just before the call to
TclFinalizeSynchronization() which effectively tears down
all allocated TSD slots (but not their data), therefore 
producing leaks.
Log in (anonymous is fine) to add a comment.