Skip to content
Tcl Source Code History Of Ticket 3400944
Login

History Of Ticket 3400944

Artifacts Associated With Ticket 3400944

  1. Ticket change [b3029448b2] (rid 98442) by dgp on 2011-08-30 18:25:04:

    1. assignee initialized to: "hobbs"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      
      Even using the special support for valgrind
      (see 2919042) testing any script with [exit]
      in it is going to show leaks of things that would
      be freed by the natural unwinding that the [exit]
      prevents.  For example,
      
      $ cat leak.tcl
      namespace eval foo exit
      
      $ valgrind --leak-check=yes ./tclsh leak.tcl
      ...
      ==13495== 36 bytes in 3 blocks are definitely lost in loss record 40 of 50
      ==13495==    at 0x4005903: malloc (vg_replace_malloc.c:195)
      ==13495==    by 0x80DF060: TclpAlloc (tclAlloc.c:705)
      ==13495==    by 0x80EF8C0: Tcl_Alloc (tclCkalloc.c:1046)
      ==13495==    by 0x80E630A: TclArgumentEnter (tclBasic.c:5473)
      ==13495==    by 0x80E5E98: TclEvalEx (tclBasic.c:5213)
      ==13495==    by 0x80E54BE: Tcl_EvalEx (tclBasic.c:4872)
      ==13495==    by 0x806D584: Tcl_FSEvalFileEx (tclIOUtil.c:1751)
      ==13495==    by 0x8072F0F: Tcl_MainEx (tclMain.c:407)
      ==13495==    by 0x8073573: Tcl_Main (tclMain.c:634)
      ==13495==    by 0x805465B: main (tclAppInit.c:84)
      ==13495==
      ==13495== 201 (48 direct, 153 indirect) bytes in 2 blocks are definitely lost in loss record 47 of 50
      ==13495==    at 0x4005903: malloc (vg_replace_malloc.c:195)
      ==13495==    by 0x80DF060: TclpAlloc (tclAlloc.c:705)
      ==13495==    by 0x80EF8C0: Tcl_Alloc (tclCkalloc.c:1046)
      ==13495==    by 0x808ED07: Tcl_NewStringObj (tclStringObj.c:340)
      ==13495==    by 0x80817A3: TclSubstTokens (tclParse.c:2337)
      ==13495==    by 0x80E5A63: TclEvalEx (tclBasic.c:5101)
      ==13495==    by 0x80E54BE: Tcl_EvalEx (tclBasic.c:4872)
      ==13495==    by 0x806D584: Tcl_FSEvalFileEx (tclIOUtil.c:1751)
      ==13495==    by 0x8072F0F: Tcl_MainEx (tclMain.c:407)
      ==13495==    by 0x8073573: Tcl_Main (tclMain.c:634)
      ==13495==    by 0x805465B: main (tclAppInit.c:84)
      
      The same issue is present using [testthread exit].
      
    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: "41. Memory Allocation"
    11. title initialized to: "[exit] creates leaks"
    12. type initialized to: "Bug"
  2. Ticket change [4f30212f33] (rid 125783) by dgp on 2011-08-31 01:25:27:

    1. assignee changed to: "ferrieux"
  3. Ticket change [87fc915d0d] (rid 131793) by dgp on 2011-08-31 01:30:05:

    1. icomment:
      
      This is relevant to the `make valgrind` target.
      It takes the test suite to be a suitable body of
      code to cover seeking leaks.  So long as the
      test suite includes use of [testthread exit] and
      similar things, though, leaks will be reported,
      likely false alarms.
      
      I suppose a constraint could be used to work
      around the matter.  Hoping for better ideas.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. subsystem changed to: "53. Configuration and Build Tools"
    5. username: "dgp"
  4. Ticket change [a28c656a91] (rid 109916) by dgp on 2011-08-31 02:33:46:

    1. icomment:
      
      I see that the Thread package docs explicitly
      warn against the [thread::exit] command in favor
      of a preserve/release system.  Lessons the
      testthread command could adopt, or the test suite
      could migrat from [testthread] to [package require Thread].
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  5. Ticket change [5d4b4196a3] (rid 115440) by ferrieux on 2011-08-31 05:23:05:

    1. icomment:
      This is similar to 3392735. Another facet :/
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  6. Ticket change [e4deab9ff9] (rid 88031) by foxcruiser on 2011-08-31 20:20:06:

    1. icomment:
      We got the same issue with [exit] when memory debugging XOTcl/NSF based on our test suite  (with an internal refcounter and valgrind). We ended up with falling back to a graceful unwind instead of Tcl_Exit(), for the scope of test scripts:
      
       proc graceFullExit {{statuscode "1"}} {
            array set map {1 ok -1 error}
            set errorcode $map($statuscode)
            interp alias {} ::exit {}
            interp expose {} exit; 
            return -code $errorcode -level [expr {[info level]-1}] "Test was exited with code $statuscode"
          }
      
      and then, before evaluating a test body:
      
       interp hide {} exit; 
       interp alias {} ::exit {} ::graceFullExit
      
      works fine for us ...
      
      
      
      
      
      
    2. login: "foxcruiser"
    3. mimetype: "text/plain"
    4. username: "foxcruiser"
  7. Ticket change [aea4f0dafc] (rid 257766) by serhiy.storchaka on 2026-10-12 17:08:05:

    1. icomment:
      Still true in 9.1: <code><nowiki>[exit]</nowiki></code> does not unwind the
      stack, so whatever the unwinding would free is reported by valgrind.
      
      A possible solution is to make <code><nowiki>[exit]</nowiki></code> unwind the
      stack, like <code>interp cancel -unwind</code>, and exit the process when the
      unwinding is complete. <code>catch</code> could not stop it, but
      <code>finally</code> clauses would run, so the script could clean up other
      resources, as with Python's <code>SystemExit</code> exception. This is a
      visible change in semantics and needs a TIP.
      
      The test suite problem was addressed as suggested here: tests which exit a
      thread in mid-operation have the <code>notValgrind</code> constraint, and
      <code><nowiki>[testthread exit]</nowiki></code> is no longer used in tests.
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"