Skip to content
Tcl Source Code History Of Ticket 3390699
Login

History Of Ticket 3390699

Artifacts Associated With Ticket 3390699

  1. Ticket change [681f8bb6e2] (rid 103009) by dgp on 2011-08-12 19:01:01:

    1. assignee initialized to: "andreas_kupries"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      
      $ make valgrind TESTFLAGS="-file socket.test -match socket_any-13.1"
      ...
      ==13528== 24 bytes in 1 blocks are definitely lost in loss record 367 of 932
      ==13528==    at 0x4005903: malloc (vg_replace_malloc.c:195)
      ==13528==    by 0x80DDD7C: TclpAlloc (in /home/dgp/fossil/tcl/unix/tcltest)
      ==13528==    by 0x80EB794: Tcl_Alloc (in /home/dgp/fossil/tcl/unix/tcltest)
      ==13528==    by 0x814010D: TEBCresume (in /home/dgp/fossil/tcl/unix/tcltest)
      ==13528==    by 0x80E0BDD: TclNRRunCallbacks (in /home/dgp/fossil/tcl/unix/tcltest)
      ==13528==    by 0x80E64BA: Tcl_EvalObjv (in /home/dgp/fossil/tcl/unix/tcltest)
      ==13528==    by 0x80E6E24: TclEvalEx (in /home/dgp/fossil/tcl/unix/tcltest)
      ==13528==    by 0x80E70D9: Tcl_EvalEx (in /home/dgp/fossil/tcl/unix/tcltest)
      
      
      ==13528== 162,248 (24 direct, 162,224 indirect) bytes in 1 blocks are definitely lost in loss record 932 of 932
      ==13528==    at 0x4005903: malloc (vg_replace_malloc.c:195)
      ==13528==    by 0x80DDD7C: TclpAlloc (in /home/dgp/fossil/tcl/unix/tcltest)
      ==13528==    by 0x80EB794: Tcl_Alloc (in /home/dgp/fossil/tcl/unix/tcltest)
      ==13528==    by 0x80890EB: SetCmdNameFromAny (in /home/dgp/fossil/tcl/unix/tcltest)
      ==13528==    by 0x808875A: Tcl_GetCommandFromObj (in /home/dgp/fossil/tcl/unix/tcltest)
      ==13528==    by 0x8132FC3: TclCompileEnsemble (in /home/dgp/fossil/tcl/unix/tcltest)
      ==13528==    by 0x8124880: TclCompileScript (in /home/dgp/fossil/tcl/unix/tcltest)
      ==13528==    by 0x812566B: TclCompileTokens (in /home/dgp/fossil/tcl/unix/tcltest)
      
      
    4. foundin initialized to: "obsolete: 8.6b2"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "dgp"
    10. subsystem initialized to: "27. Channel Types"
    11. title initialized to: "socket_any-13.1 leaks"
    12. type initialized to: "Bug"
  2. Ticket change [120dc7c7d8] (rid 95247) by dgp on 2011-08-13 02:08:07:

    1. icomment:
      
      Similar results for socket_inet-13.1
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. title changed to: "socket_*-13.1 leaks"
    5. username: "dgp"
  3. Ticket change [668cf2669a] (rid 102730) by dgp on 2011-08-13 03:19:12:

    1. icomment:
      
      Leak trouble may be lurking in [tcltest::threadReap]
      which is problematic in oh so many ways....
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  4. Ticket change [1f7e18e4ac] (rid 91154) by ferrieux on 2011-08-13 18:35:39:

    1. icomment:
      Yes. Currently, threadReap essentially does testthread::send -async exit, and waits very little.
      What about doing a testthread::join to resynchronize with their proper termination ?
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  5. Ticket change [d8f115fe58] (rid 107528) by ferrieux on 2011-08-13 21:11:02:

    1. icomment:
      Hmm, looking again, threadReap does wait, though in a strange manner. Essentially:
      
      while {[llength [testthread names]] > 1} {
          foreach tid [testthread names] {
              testthread send -async $tid {testthread exit}
          }
                  after 1
      }
      
      This implies that if one of the threads blocks (possibly forever), tons of such scriptlets will accumulate in its input interthread queue...
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  6. Ticket change [c4427c17db] (rid 111819) by ferrieux on 2011-08-13 23:11:03:

    1. icomment:
      Anyway, single-stepping through the thread's end shows that testthread::exit does *not* do the same as falling thru.
      Notably, the Tcl_DeleteInterp() is omitted, which would account for the leak (the Interp object itself !).
      However, when trying to give back symmetry (with the attached patch), on encounters a secondary problem. In DeleteInterpProc, the test
      
          /*
           * Punt if there is an error in the Tcl_Release/Tcl_Preserve matchup,
       * unless we are exiting.
           */
          if ((iPtr->numLevels > 0) && !TclInExit()) {
      Tcl_Panic("DeleteInterpProc called with active evals");
          }
      
      panics in that case. Of course numLevels is >0 (it is 2) because "exit" is called from within an event handler... as is most often the case.
      
      I suspect that is the reason why the original author (stanton, <=1999) removed DeleteInterp from the sequence, but  that's pulling it under the rug.
      
      Still digging to understand how the equivalent situation is handled in [exit].
      
      Q1: why such a stringent test (panicking if it fails) ?
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  7. Ticket change [c86f7316b4] (rid 122104) by ferrieux on 2011-08-13 23:18:26:

    1. icomment:
      Answer to last question: this is done by checking the global TclInExit flag. So we want a similar per-thread one, though one that is set earlier than TclInThreadExit. That's additionally tricky because the test is deep inside hi-speed code in tclExecute.c, some without even an interp around...
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  8. Ticket change [18c19a728c] (rid 122716) by ferrieux on 2011-08-13 23:44:13:

    1. icomment:
      Some progress. I disabled the various panicky checks just to explore "what if" without spending the time of the optimized new "thread prepared to exit" test. 
      
      Then I observed two things:
      
       - there is a race condition due to threadRep just waiting for the higher-level [thread names] to deplete instead of joining. When the thread is near the end and has removed itself from the list, the main thread quickly goes to [exit] and doesn't leave a chance for the other thread to finish its cleanups.
      
       - after adding a [threadtest join] in threadReap's loop (and a -joinable at thread creation in socket.test), the leak bill is much reduced:
      
      ==4495==    definitely lost: 84 bytes in 4 blocks
      ==4495==    indirectly lost: 3,012 bytes in 77 blocks
      ==4495==      possibly lost: 136 bytes in 1 blocks
      ==4495==    still reachable: 418 bytes in 15 blocks
      ==4495==         suppressed: 0 bytes in 0 blocks
      
      
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  9. Ticket change [e15d9c82d5] (rid 87434) by ferrieux on 2011-08-13 23:48:05:

    1. icomment:
      
      
      File Added - 421045: thr2.patch
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  10. Add attachment "thr2.patch" [6d2930046a] (rid 128642) by ferrieux on 2011-08-13 23:48:05.

  11. Ticket change [7dac681fe0] (rid 97282) by ferrieux on 2011-08-17 05:48:52:

    1. icomment:
      Deferring until the more general 3392735 is solved (incomplete freeing of active levels).
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  12. Ticket change [0e8afd034c] (rid 94634) by dgp on 2011-09-12 03:02:32:

    1. icomment:
      
      Leak is in the test, not the tested code.
      Fixed via conversion from [testthread] to Thread package.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  13. Ticket change [74848dfc3f] (rid 105217) by dgp on 2011-09-12 03:02:33:

    1. assignee changed to: "dgp"
    2. closedate changed to: "2011-09-11T20:02:33"
    3. closer changed to: "dgp"
    4. icomment:
      
      
      allow_comments - 1
      
      
      
    5. login: "dgp"
    6. mimetype: "text/plain"
    7. resolution changed to: "Fixed"
    8. status changed to: "Closed"
    9. username: "dgp"