TclOO segmentation fault: direct call to a method called by the object destructor, and that deletes the object via [rename] before calling [next]
oo::class create c1 {
method m1 {} {}
}
oo::class create c2 {
superclass c1
destructor {
my m1
}
method m1 {} {
rename [self] {}
next
# nextto c1
}
}
c2 create obj1
obj1 m1
0107393da7fixes bug [135804138e] check-in2019-11-14 19:30:23c9e01c1cdcfixed SF [135804138e] -- no call of next possible after object namespace is deleted check-in2019-11-14 17:06:061b14cba0a8bug [135804138e]: test case illustrating the segfault check-in2019-11-14 17:04:39
I do not see where/how `m2` is invoked. And it seems to be an incomplete method definition as well.
I suspect that the script should be:
oo::class create c1 {
method m1 {} {}
}
oo::class create c2 {
superclass c1
destructor {
my m1
}
method m1 {} {
my m2
next
}
method m2 {} {
rename [self] {}
}
}
c2 create obj1
obj1 m1
The initial script is the wrong script. This is the correct script to reproduce the segmentation fault:
oo::class create c1 {
method m1 {} {}
}
oo::class create c2 {
superclass c1
destructor {
my m1
}
method m1 {} {
rename [self] {}
next
}
}
c2 create obj1
obj1 m1
Fixed now in branch bug-135804138e...
I had 2 variants to solve that.
In the 1st variant the result of test-case oo-7.10 would be something like:
So the "next" had successfully called "c1::m1" second time, so it had assumed that only context of object is deleted (not a class in the call chain) and all access to my/self etc would be prohibited anyway, but just because "c1::m1" behaves like a proc (without object context access) it were possible without any issue to call it second time.
- delete c2::destructor delete no-self c1::m1 unreachable /c2::destructor no-self 1 {no next method implementation}
+ delete c2::destructor delete no-self c1::m1 unreachable /c2::destructor no-self c1::m1 unreachable 0 {}
The interim decision was another variant (as it is currently implemented in branch bug-135804138e) is calling of "next" is impossible after object deletion - so it throws an error there.