Ticket UUID: | 135804138e33ff05b89f06101008113c86156322 | |||
Title: | TclOO segmentation fault: direct call to a method called by the object destructor, and that deletes the object via [rename] before calling [next] | |||
Type: | Bug | Version: | ||
Submitter: | pooryorick | Created on: | 2019-11-13 21:20:59 | |
Subsystem: | 35. TclOO Package | Assigned To: | sebres | |
Priority: | 5 Medium | Severity: | Minor | |
Status: | Closed | Last Modified: | 2019-11-14 19:36:01 | |
Resolution: | Fixed | Closed By: | pooryorick | |
Closed on: | 2019-11-14 19:36:01 | |||
Description: |
(text/x-fossil-wiki)
The following script results in a segmentation fault in core-8-6-branch: <code><verbatim> 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 </verbatim></code> | |||
User Comments: |
sebres added on 2019-11-14 17:22:34:
(text/x-fossil-wiki)
Fixed now in branch [/timeline?r=bug-135804138e|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: <code><pre style="padding-left:10pt"> <b style="color:red">- delete c2::destructor delete no-self c1::m1 unreachable /c2::destructor no-self 1 {no next method implementation}</b> <b style="color:green">+ delete c2::destructor delete no-self c1::m1 unreachable /c2::destructor no-self c1::m1 unreachable 0 {}</b> </pre></code> 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 [/timeline?r=bug-135804138e|bug-135804138e]) is calling of "next" is impossible after object deletion - so it throws an error there. pooryorick added on 2019-11-14 09:43:25: (text/x-fossil-wiki) The initial script is the wrong script. This is the correct script to reproduce the segmentation fault: <code><verbatim> 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 </verbatim></code> aku added on 2019-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 aku added on 2019-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. |