Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2019-11-14
19:36 • Closed ticket [135804138e]: TclOO segmentation fault: direct call to a method c... artifact: 1a203f3ea1 user: pooryorick
19:30
fixes bug [135804138e] check-in: 0107393da7 user: sebres tags: core-8-6-branch
17:22 • Pending ticket [135804138e]: TclOO segmentation fault: direct call to a method ... artifact: 4965e7034f user: sebres
17:06
fixed SF [135804138e] -- no call of next possible after object namespace is deleted check-in: c9e01c1cdc user: sebres tags: bug-135804138e
17:04
bug [135804138e]: test case illustrating the segfault check-in: 1b14cba0a8 user: sebres tags: bug-135804138e
14:49 • Ticket [135804138e] TclOO segmentation fault: direct call to a method called by... artifact: 45c0f4109c user: pooryorick
14:46 • Ticket [135804138e]: 4 changes artifact: cb03b664de user: sebres
09:43 • Ticket [135804138e]: 3 changes artifact: 6648696fde user: pooryorick
2019-11-13
21:35 • Ticket [135804138e]: 3 changes artifact: 2b003b1e12 user: aku
21:32 • Ticket [135804138e]: 3 changes artifact: 7a7347db21 user: aku
21:20 • New ticket [135804138e]. artifact: 83c0da4d73 user: pooryorick

TclOO segmentation fault: direct call to a method called by the object destructor, and that deletes the object via [rename] before calling [next]

Closed / Fixed135804138e33ff05b89f06101008113c86156322Created 7 years agoUpdated 7 years ago
Descriptionwiki2019-11-13 21:20:59
The following script results in a segmentation fault in core-8-6-branch:

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
Referenced by3
akuplain2019-11-13 21:32:40
I do not see where/how `m2` is invoked.
And it seems to be an incomplete method definition as well.
akuplain2019-11-13 21:35:26
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
pooryorickwiki2019-11-14 09:43:25

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

sebres Ticket [135804138e]: 4 changes [History diff]2019-11-14 14:46:10
pooryorick Ticket [135804138e]: 3 changes [History diff]2019-11-14 14:49:48
sebreswiki2019-11-14 17:22:34

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:

- 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 {}
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.

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.

pooryorick Closed ticket [135804138e]. [History diff]2019-11-14 19:36:01
Log in (anonymous is fine) to add a comment.