Skip to content
Tcl Source Code History Of Ticket 3493120fffffffffffffffffffffffffffffffff
Login

History Of Ticket 3493120fffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 3493120fffffffffffffffffffffffffffffffff

  1. Ticket change [056ea50222] (rid 89065) by sebres on 2012-02-24 13:33:32:

    1. assignee initialized to: "andreas_kupries"
    2. cmimetype initialized to: "text/plain"
    3. 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
      
      
    4. foundin initialized to: "obsolete: 8.5.11"
    5. is_private initialized to: "0"
    6. priority initialized to: "7 High"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "sebres"
    10. subsystem initialized to: "49. Threading"
    11. title initialized to: "Thread extension, memory leak after threa exit"
    12. type initialized to: "Bug"
  2. Ticket change [0e3963c365] (rid 94578) by sebres on 2012-02-24 20:33:55:

    1. title changed to: "Thread extension, memory leak after thread exit"
  3. Ticket change [cdebcae748] (rid 95971) by sebres on 2012-02-24 20:40:05:

    1. icomment:
      tested with thread2.6.5, thread2.6.7 and current thread-2-7-branch
      
      
    2. login: "sebres"
    3. mimetype: "text/plain"
    4. username: "sebres"
  4. Ticket change [66c442d1db] (rid 102777) by kennykb on 2012-02-26 02:00:42:

    1. subsystem changed to: "80. Thread Package"
  5. Ticket change [2cfa83ae24] (rid 119007) by sebres on 2012-02-28 17:29:55:

    1. 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
      
      
      
    2. login: "sebres"
    3. mimetype: "text/plain"
    4. username: "sebres"
  6. Ticket change [8df95cc96f] (rid 128035) by sebres on 2012-02-28 17:52:37:

    1. icomment:
      much short variant of leak test :
      
      puts [thread::names]
      time {
        thread::create {::thread::release}
      } 500
      puts [thread::names]
      
      
    2. login: "sebres"
    3. mimetype: "text/plain"
    4. username: "sebres"
  7. Ticket change [35cdd7bbb8] (rid 137726) by sebres on 2014-04-22 13:28:58:

    1. assignee changed to: "aku"
    2. closer changed to: "nobody"
    3. 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
      
    4. 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.
      
    5. login: "sebres"
    6. mimetype: "text/plain"
    7. severity changed to: "Minor"
    8. username: "sebres"
  8. Ticket change [2e9ced0a19] (rid 137727) by sebres on 2014-04-22 13:38:00:

    1. assignee changed to: "nobody"
    2. foundin changed to: "all"
    3. icomment: "Reviews and tests are welcome"
    4. login: "sebres"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Pending"
    8. subsystem changed to: "49. Threading"
    9. username: "sebres"
  9. Ticket change [aa94e38ef8] (rid 137737) by sebres on 2014-04-22 17:44:30:

    1. 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]
      
    2. 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.
      
    3. login: "sebres"
    4. mimetype: "text/html"
    5. username: "sebres"
  10. Ticket change [6c81c020e9] (rid 137739) by dgp on 2014-04-22 20:02:23:

    1. icomment:
      Same troubles on Mavericks OSX.
      
      Just try to run the test suite on a
      
      ./configure --disable-shared --enable-threads --enable-symbols
      
      build.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  11. Ticket change [f7ba79b9a2] (rid 137740) by dgp on 2014-04-22 20:02:29:

    1. icomment:
      Same troubles on Mavericks OSX.
      
      Just try to run the test suite on a
      
      ./configure --disable-shared --enable-threads --enable-symbols
      
      build.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  12. Ticket change [c97297853a] (rid 137742) by sebres on 2014-04-23 09:19:41:

    1. 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.
      
    2. login: "sebres"
    3. mimetype: "text/plain"
    4. username: "sebres"
  13. Ticket change [e300ce18e7] (rid 137743) by dgp on 2014-04-23 18:26:14:

    1. assignee changed to: "sebres"
    2. closedate changed to: "2456771.26822016"
    3. closer changed to: "dgp"
    4. icomment:
      That solved it.  Thanks!
      
      Merging now...
      
    5. login: "dgp"
    6. mimetype: "text/plain"
    7. status changed to: "Closed"