Artifacts Associated With Ticket 3493120fffffffff
Ticket change [056ea50222] (rid 89065) by sebres on 2012-02-24 13:33:32:
- assignee initialized to: "andreas_kupries"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Version: 8.5.11 (original and current core-8-5-branch) Platform: Windows (linux not yet tested) After exiting of threads, they leave a memory leak. Consequence of that: we cannot use techniques such as 'idletime' (to release some system resources, for example large tcl codes are no more used, etc, etc.). After run of following script I have lost 100MB of memory. In fact, nothing will be done here, except threads are created and exited. Test script: # for test purposes - to wait for threads exited : tsv::set testth count 0 # this create once a thread pool, and generate jobs : proc test {} { # create a thread pool if not yet already exists : if {![llength [tpool::names]]} { tpool::create -minworkers 0 -maxworkers 5 -idletime 1 -initcmd { # + 1 thread tsv::set testth count [expr {[tsv::get testth count] + 1}]; puts [thread::id]init!!!!! } -exitcmd { # - 1 thread tsv::set testth count [expr {[tsv::get testth count] - 1}]; puts [thread::id]!!!!!exit } } # generate jobs until 5 threads are created : while {[tsv::get testth count] < 5} { tpool::post -detached -nowait [lindex [tpool::names] 0] { puts [thread::id]!!job; tsv::array unset testthcount [thread::id] } update } } # repeat test 100 times, in addition waiting for the # threads to be finished each iteration : time {test; while {[tsv::get testth count]} {after 10};} 100 - foundin initialized to: "obsolete: 8.5.11"
- is_private initialized to: "0"
- priority initialized to: "7 High"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "sebres"
- subsystem initialized to: "49. Threading"
- title initialized to: "Thread extension, memory leak after threa exit"
- type initialized to: "Bug"
Ticket change [0e3963c365] (rid 94578) by sebres on 2012-02-24 20:33:55:
- title changed to: "Thread extension, memory leak after thread exit"
Ticket change [cdebcae748] (rid 95971) by sebres on 2012-02-24 20:40:05:
- icomment:
tested with thread2.6.5, thread2.6.7 and current thread-2-7-branch
- login: "sebres"
- mimetype: "text/plain"
- username: "sebres"
- icomment:
Ticket change [66c442d1db] (rid 102777) by kennykb on 2012-02-26 02:00:42:
- subsystem changed to: "80. Thread Package"
Ticket change [2cfa83ae24] (rid 119007) by sebres on 2012-02-28 17:29:55:
- icomment:
It seems to be a problem with tcl core (threaded memory subsystem etc.) - I made a test without thread.dll, where I create threads with WinAPI, call inits and hereafter finalize - leak remains. Following singlethreaded script runs without leak also: time { try { set ntp [interp create] $ntp eval "load thread27" } finally { interp delete $ntp } } 500 - login: "sebres"
- mimetype: "text/plain"
- username: "sebres"
- icomment:
Ticket change [8df95cc96f] (rid 128035) by sebres on 2012-02-28 17:52:37:
- icomment:
much short variant of leak test : puts [thread::names] time { thread::create {::thread::release} } 500 puts [thread::names] - login: "sebres"
- mimetype: "text/plain"
- username: "sebres"
- icomment:
Ticket change [35cdd7bbb8] (rid 137726) by sebres on 2014-04-22 13:28:58:
- assignee changed to: "aku"
- closer changed to: "nobody"
- comment changed to:
Version: 8.5.11 (original and current core-8-5-branch) Platform: Windows (linux not yet tested) After exiting of threads, they leave a memory leak. Consequence of that: we cannot use techniques such as 'idletime' (to release some system resources, for example large tcl codes are no more used, etc, etc.). After run of following script I have lost 100MB of memory. In fact, nothing will be done here, except threads are created and exited. Test script: # for test purposes - to wait for threads exited : tsv::set testth count 0 # this create once a thread pool, and generate jobs : proc test {} { # create a thread pool if not yet already exists : if {![llength [tpool::names]]} { tpool::create -minworkers 0 -maxworkers 5 -idletime 1 -initcmd { # + 1 thread tsv::set testth count [expr {[tsv::get testth count] + 1}]; puts [thread::id]init!!!!! } -exitcmd { # - 1 thread tsv::set testth count [expr {[tsv::get testth count] - 1}]; puts [thread::id]!!!!!exit } } # generate jobs until 5 threads are created : while {[tsv::get testth count] < 5} { tpool::post -detached -nowait [lindex [tpool::names] 0] { puts [thread::id]!!job; tsv::array unset testthcount [thread::id] } update } } # repeat test 100 times, in addition waiting for the # threads to be finished each iteration : time {test; while {[tsv::get testth count]} {after 10};} 100 - icomment:
Leak found and fixed within [c251d61424] TclpFreeAllocCache (if called with ptr != NULL) has a comment: "Called by us in TclpFinalizeThreadData when a thread exits ..." But until now it was really never called. After fixing, no byte is lost during test.
- login: "sebres"
- mimetype: "text/plain"
- severity changed to: "Minor"
- username: "sebres"
Ticket change [2e9ced0a19] (rid 137727) by sebres on 2014-04-22 13:38:00:
- assignee changed to: "nobody"
- foundin changed to: "all"
- icomment: "Reviews and tests are welcome"
- login: "sebres"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Pending"
- subsystem changed to: "49. Threading"
- username: "sebres"
Ticket change [aa94e38ef8] (rid 137737) by sebres on 2014-04-22 17:44:30:
- comment changed to:
Version: 8.5.11 (original and current core-8-5-branch) Platform: Windows (linux not yet tested) After exiting of threads, they leave a memory leak. Consequence of that: we cannot use techniques such as 'idletime' (to release some system resources, for example large tcl codes are no more used, etc, etc.). After run of following script I have lost 100MB of memory. In fact, nothing will be done here, except threads are created and exited. Test script: puts [thread::names] time { thread::create {::thread::release} } 500 puts [thread::names] - icomment:
I can't test CentOS right now, but it work on all my linux systems, for ex.: debian / kernel 3.13.0-23-generic. I think, possible in tclUnixThrd.c TclpFreeAllocCache may miss a something like "pthread_setspecific(key, NULL);" after call of "TclFreeAllocCache(ptr);" (in comparison to tclWinThrd.c). But [c251d61424] alone, without this, works fine on my linux mashines. <pre> void TclpFreeAllocCache( void *ptr) { if (ptr != NULL) { /* * Called by the pthread lib when a thread exits */ TclFreeAllocCache(ptr); <b style="color:red">pthread_setspecific(key, NULL);</b> } else if (initialized) { /* * Called by us in TclFinalizeThreadAlloc() during the library * finalization initiated from Tcl_Finalize() */ pthread_key_delete(key); initialized = 0; } } </pre> @Don: could you tell me please where exactly you have segfaulting on centos (some tcl-tests? or something else?), because I can't reproduce it on my linux systems. - login: "sebres"
- mimetype: "text/html"
- username: "sebres"
- comment changed to:
Ticket change [6c81c020e9] (rid 137739) by dgp on 2014-04-22 20:02:23:
- icomment:
Same troubles on Mavericks OSX. Just try to run the test suite on a ./configure --disable-shared --enable-threads --enable-symbols build.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [f7ba79b9a2] (rid 137740) by dgp on 2014-04-22 20:02:29:
- icomment:
Same troubles on Mavericks OSX. Just try to run the test suite on a ./configure --disable-shared --enable-threads --enable-symbols build.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [c97297853a] (rid 137742) by sebres on 2014-04-23 09:19:41:
- icomment:
*nix segfault cleared: we should reset a thread key after freeing of alloc cache (in tclUnixThrd.c); Fixed within [1dc6ea5ab2]; @Don: could you please test it on CentOS and OSX.
- login: "sebres"
- mimetype: "text/plain"
- username: "sebres"
- icomment:
Ticket change [e300ce18e7] (rid 137743) by dgp on 2014-04-23 18:26:14:
- assignee changed to: "sebres"
- closedate changed to: "2456771.26822016"
- closer changed to: "dgp"
- icomment:
That solved it. Thanks! Merging now...
- login: "dgp"
- mimetype: "text/plain"
- status changed to: "Closed"