Artifacts Associated With Ticket 708422
Ticket change [4262691a9c] (rid 233045) by andy on 2024-09-04 04:13:52:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-markdown"
- comment initialized to:
unset traces can inject arbitrary code right in the middle of destroying an object. In this halfway state, the object command exists, [info object isa object] says it's valid, but the object namespace is gone. Deleting the object namespace is what triggers the unset trace. The following code dies with SIGSEGV inside TclOOGetCallContext (tclOOCall.c:1024) when it does `oPtr->selfCls->classChainCache != NULL` because `oPtr->selfCls` is NULL. ``` oo::class create foo { variable x constructor {} { trace add variable x unset [list apply {{self ns args} { puts [list args -> $args] puts [list info object isa object $self -> [info object isa object $self]] puts [list namespace exists $ns -> [namespace exists $ns]] $self test }} [self] [self namespace]] } method test {} {} } [foo new] destroy ``` The above prints: ``` args -> {::oo::Obj12::x {} unset} info object isa object ::oo::Obj12 -> 1 namespace exists ::oo::Obj12 -> 0 Segmentation fault (core dumped) ``` For now, my workaround is to check for namespace existence in my unset trace, allowing me to distinguish between variables being unset for normal reasons and variables being unset because the object is being destroyed. - foundin initialized to: "8.6.14"
- is_private initialized to: "0"
- login: "andy"
- priority initialized to: "5 Medium"
- private_contact initialized to: "662c23482b0bf6a505f39e48fb7ad43af8dee4d3"
- resolution initialized to: "None"
- severity initialized to: "Severe"
- status initialized to: "Open"
- submitter initialized to: "andy"
- subsystem initialized to: "35. TclOO Package"
- title initialized to:
unset traces enable calling a class method mid-destruction
- type initialized to: "Bug"
Ticket change [8c58c636c1] (rid 233046) by andy on 2024-09-04 04:15:01:
- login: "andy"
- mimetype: "text/plain"
- title changed to:
unset traces enable calling an object command mid-destruction
Ticket change [28f2698f04] (rid 233280) by oehhar on 2024-09-09 08:46:19:
- icomment:
TTT meeting today accknowledged this bug but does not want to delay 9.0.0 for this. It is planned to address this in 9.0.1. Harald
- login: "oehhar"
- mimetype: "text/x-fossil-wiki"
- username: "oehhar"
- icomment:
Ticket change [2cd2a0298b] (rid 233488) by dkf on 2024-09-16 14:58:29:
- icomment:
This is very tricky. The problem is that once the namespace itself has started to go, lookup of things gets *very very* messy. I'd not thought about using unset traces to put callbacks in at that point; I need to extend the battery of tests for destruction sequences a bit more. I'm guessing that the resolution will be to make `$self test` fail to dispatch with an error once destruction has advanced that far... but I'm not sure about that. That there will be *some* sort of error is pretty much certain... except it might not be easily observable (or maybe it will if you have the event loop going). Prefer destructors; they get run at a time when things are more reliable. When run via the `destroy` method, they can even report Tcl errors correctly. (The object is still destroyed, but you get a nice error.) ---- Thank you for reporting this!
- login: "dkf"
- mimetype: "text/x-markdown"
- icomment:
Ticket change [717fa13bde] (rid 233489) by dkf on 2024-09-16 15:58:21:
- assignee changed to: "dkf"
- icomment:
Seems to be a duplicate of [7842f33a5c], which wasn't fixed in 8.6.14 but has been fixed since. But I like the test case.
- login: "dkf"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Duplicate"
- status changed to: "Pending"
Ticket change [9b2794e199] (rid 233509) by dkf on 2024-09-17 08:36:44:
- closedate changed to: "2460570.85884954"
- closer changed to: "dkf"
- login: "dkf"
- mimetype: "text/plain"
- status changed to: "Closed"