|
2024-09-19
| ||
| 10:05 | Merge [8e0ee072e2857992]: [708422] Nice test case. Bug report duplicates [7842f33a5c]. check-in: 71e5b88a95 user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE | |
|
2024-09-17
| ||
| 08:36 | • Closed ticket [708422a066]: unset traces enable calling an object command mid-de... artifact: 9b2794e199 user: dkf | |
|
2024-09-16
| ||
| 16:05 | [708422] Nice test case. Bug report duplicates [7842f33a5c] check-in: be14e8b90e user: dkf tags: core-8-branch | |
| 15:58 | • Pending ticket [708422a066]: unset traces enable calling an object command mid-d... artifact: 717fa13bde user: dkf | |
| 14:58 | • Ticket [708422a066]: 3 changes artifact: 2cd2a0298b user: dkf | |
|
2024-09-09
| ||
| 08:46 | • Ticket [708422a066]: 4 changes artifact: 28f2698f04 user: oehhar | |
|
2024-09-04
| ||
| 04:15 | • Ticket [708422a066]: 3 changes artifact: 8c58c636c1 user: andy | |
| 04:13 | • New ticket [708422a066]. artifact: 4262691a9c user: andy | |
unset traces enable calling an object command mid-destruction
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.
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
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!
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.