From f00d9f9d02d293675899b1c0ce23aa5cb641cd92 Mon Sep 17 00:00:00 2001 From: sebres Date: Thu, 14 Nov 2019 17:04:39 +0000 Subject: bug [135804138e]: test case illustrating the segfault --- tests/oo.test | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/oo.test b/tests/oo.test index b0704da..55018e9 100644 --- a/tests/oo.test +++ b/tests/oo.test @@ -1353,6 +1353,35 @@ test oo-7.9 {OO: defining inheritance in namespaces} -setup { return } } -result {} +test oo-7.10 {OO: next after object deletion, bug [135804138e]} -setup { + set ::result "" + oo::class create c1 { + method m1 {} { + lappend ::result c1::m1 + } + } + oo::class create c2 { + superclass c1 + destructor { + lappend ::result c2::destructor + my m1 + lappend ::result /c2::destructor + } + method m1 {} { + lappend ::result delete + rename [self] {} + lappend ::result no-self + next + lappend ::result unreachable + } + } +} -body { + c2 create o + lappend ::result [catch {o m1} msg] $msg +} -cleanup { + c1 destroy + unset ::result +} -result {delete c2::destructor delete no-self c1::m1 unreachable /c2::destructor no-self 1 {no next method implementation}} test oo-8.1 {OO: global must work in methods} { oo::object create foo -- cgit v0.12 From b098fb32795b2f8e09c277d0d306986a6f5a9c7e Mon Sep 17 00:00:00 2001 From: sebres Date: Thu, 14 Nov 2019 17:06:06 +0000 Subject: fixed SF [135804138e] -- no call of next possible after object namespace is deleted --- generic/tclOOMethod.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generic/tclOOMethod.c b/generic/tclOOMethod.c index 3e64ba2..fbd23c0 100644 --- a/generic/tclOOMethod.c +++ b/generic/tclOOMethod.c @@ -671,11 +671,11 @@ InvokeProcedureMethod( * call frame's lifetime). */ /* - * If the interpreter was deleted, we just skip to the next thing in the - * chain. + * If the object namespace (or interpreter) were deleted, we just skip to + * the next thing in the chain. */ - if (Tcl_InterpDeleted(interp)) { + if (!((CallContext *)context)->oPtr->namespacePtr) { return TclNRObjectContextInvokeNext(interp, context, objc, objv, Tcl_ObjectContextSkippedArgs(context)); } -- cgit v0.12 From 05b4cb2080209949f44fdf00e08a044584bffe73 Mon Sep 17 00:00:00 2001 From: sebres Date: Thu, 14 Nov 2019 17:41:51 +0000 Subject: make oo-7.10 test more readable --- tests/oo.test | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/oo.test b/tests/oo.test index 55018e9..77fca68 100644 --- a/tests/oo.test +++ b/tests/oo.test @@ -1368,11 +1368,11 @@ test oo-7.10 {OO: next after object deletion, bug [135804138e]} -setup { lappend ::result /c2::destructor } method m1 {} { - lappend ::result delete + lappend ::result c2::m1 rename [self] {} lappend ::result no-self next - lappend ::result unreachable + lappend ::result /c2::m1 } } } -body { @@ -1381,7 +1381,7 @@ test oo-7.10 {OO: next after object deletion, bug [135804138e]} -setup { } -cleanup { c1 destroy unset ::result -} -result {delete c2::destructor delete no-self c1::m1 unreachable /c2::destructor no-self 1 {no next method implementation}} +} -result {c2::m1 c2::destructor c2::m1 no-self c1::m1 /c2::m1 /c2::destructor no-self 1 {no next method implementation}} test oo-8.1 {OO: global must work in methods} { oo::object create foo -- cgit v0.12 From 434361c3c66494a5fb28d24bdf591b9ac803673c Mon Sep 17 00:00:00 2001 From: sebres Date: Thu, 14 Nov 2019 19:22:46 +0000 Subject: restore verification for deleted interp --- generic/tclOOMethod.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/generic/tclOOMethod.c b/generic/tclOOMethod.c index fbd23c0..0c5f4bb 100644 --- a/generic/tclOOMethod.c +++ b/generic/tclOOMethod.c @@ -675,7 +675,9 @@ InvokeProcedureMethod( * the next thing in the chain. */ - if (!((CallContext *)context)->oPtr->namespacePtr) { + if (!((CallContext *)context)->oPtr->namespacePtr || + Tcl_InterpDeleted(interp) + ) { return TclNRObjectContextInvokeNext(interp, context, objc, objv, Tcl_ObjectContextSkippedArgs(context)); } -- cgit v0.12