Skip to content
Tcl Source Code History Of Ticket 28de60cef5
Login

History Of Ticket 28de60cef5

Artifacts Associated With Ticket 28de60cef5

  1. Ticket change [d76b6e5673] (rid 179200) by cyan on 2020-02-16 10:44:05:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      I'm not sure this is the right place for this (maybe Thread?), but I've hit a
      segfault that involves the timing of an object's namespace deletion.  I'm
      filing it against TclOO because I've hit a similar issue with a destructor
      implemented in c that doesn't involve tsv::lock, but the this version uses only
      Tcl script and standard packages distributed with Tcl releases:
      
      package require Thread
      
      oo::class create foo {
          variable thing
      
          constructor {} {
              set thing something
          }
      
          destructor {
              set local $thing
              rename [self] {}
              tsv::lock foo {
                  puts "local: $local"   ;# works
                  puts "thing: $thing"   ;# segfault
              }
          }
      }
      
      [foo new] destroy
      
      
      I admit that "rename [self] {}" in the destructor is silly, but it works if the
      tsv::lock isn't involved, and it's there to simulate the situation that occurs
      in the real code where I found this problem, where it is less silly.
      
      The crash happens on a call to
      Tcl_CreateHashEntry(TclVarTable(contextPtr->oPtr->namespacePtr) in
      ProcedureMethodCompiledVarConnect where contextPtr->oPtr->namespacePtr is NULL.
      
      In the possibly related case with a C method and destructor, the C method does
      a Tcl_DeleteCommandFromToken(interp, thisObjectCommand) on itself for the side
      effect of destroying the instance (if a more direct way of doing this exists
      please point me to it).  Sometimes this does the expected thing and calls the
      destructor before returning from the Tcl_DeleteCommandFromToken, but  under
      other circumstances (haven't found the relevant trigger yet, maybe NR context?)
      it chains to the destructor after the c method that called
      Tcl_DeleteCommandFromToken returns.  But in that case (without calling the
      destructor yet) all the object metadata has been removed and the namespace
      deleted when Tcl_DeleteCommandFromToken returns, causing some difficulties for
      the destructor when it runs later.
      
    5. foundin initialized to: "8.6.*, 8.7a3"
    6. is_private initialized to: "0"
    7. login: "cyan"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "54152f94cb1628c0c148b4b5708ace53216227b0"
    10. resolution initialized to: "None"
    11. severity initialized to: "Severe"
    12. status initialized to: "Open"
    13. submitter initialized to: "cyan"
    14. subsystem initialized to: "10. Objects"
    15. title initialized to: "Segfault in destructor using tsv::lock"
    16. type initialized to: "Bug"
  2. Ticket change [42d6509f0a] (rid 257927) by serhiy.storchaka on 2026-10-13 15:27:14:

    1. foundin changed to: "8.6.18, 9.0.5, 9.1.0"
    2. icomment:
      Still crashes with 8.6.17, 9.0 and 9.1. It does not need Thread:
      <code>eval</code> or <code>uplevel 0</code> instead of
      <code>tsv::lock</code> crash the same way. <code><nowiki>rename [self] {}</nowiki></code> deletes
      the namespace of the object, and the variable resolver of TclOO then looks up
      the variable in the deleted namespace.
      
      Proposed fix in branch [/timeline?r=oo-destructor-deleted-namespace|oo-destructor-deleted-namespace]:
      do not resolve object variables when the namespace is already deleted; reading
      such a variable is then an error. Test oo-3.13.
      
    3. login: "serhiy.storchaka"
    4. mimetype: "text/x-fossil-wiki"
  3. Ticket change [56956b0708] (rid 261050) by dkf on 2026-11-01 20:37:55:

    1. closedate changed to: "2461346.3596696989"
    2. closer changed to: "dkf"
    3. icomment:
      It was a missing `NULL` check. Ought to be fixed now (9.0 onwards).
      
    4. login: "dkf"
    5. mimetype: "text/x-markdown"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. subsystem changed to: "35. TclOO Package"