From 3c1b7f78dc3d31142226b8c29cce38d5d3a86f03 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 13 Aug 2020 12:42:38 +0000 Subject: Backout uncomplete fix for [3422267ed6b79922]: segmentation fault from deleting the the target of an imported alias during a trace on the target of the alias. Since it causes build failures. --- generic/tclNamesp.c | 7 +------ generic/tclProc.c | 7 ------- tests/interp.test | 37 ------------------------------------- 3 files changed, 1 insertion(+), 50 deletions(-) diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index fea23aa..26dca62 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -959,7 +959,7 @@ Tcl_DeleteNamespace( /* * If the namespace has associated ensemble commands, delete them first. * This leaves the actual contents of the namespace alone (unless they are - * linked ensemble commands, of course). This code is + * linked ensemble commands, of course). Note that this code is actually * reentrant so command delete traces won't purturb things badly. */ @@ -1770,9 +1770,7 @@ DoImport( TclInvokeImportedCmd, InvokeImportedNRCmd, dataPtr, DeleteImportedCmd); dataPtr->realCmdPtr = cmdPtr; - cmdPtr->refCount++; dataPtr->selfPtr = (Command *) importedCmd; - dataPtr->selfPtr->refCount++; dataPtr->selfPtr->compileProc = cmdPtr->compileProc; Tcl_DStringFree(&ds); @@ -1783,7 +1781,6 @@ DoImport( refPtr = (ImportRef *)ckalloc(sizeof(ImportRef)); refPtr->importedCmdPtr = (Command *) importedCmd; - refPtr->importedCmdPtr->refCount++; refPtr->nextPtr = cmdPtr->importRefPtr; cmdPtr->importRefPtr = refPtr; } else { @@ -2079,9 +2076,7 @@ DeleteImportedCmd( } else { prevPtr->nextPtr = refPtr->nextPtr; } - TclCleanupCommandMacro(refPtr->importedCmdPtr); ckfree(refPtr); - TclCleanupCommandMacro(selfPtr) ckfree(dataPtr); return; } diff --git a/generic/tclProc.c b/generic/tclProc.c index 150d036..0d67c37 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -215,7 +215,6 @@ Tcl_ProcObjCmd( */ procPtr->cmdPtr = (Command *) cmd; - procPtr->cmdPtr->refCount++; /* * TIP #280: Remember the line the procedure body is starting on. In a @@ -2155,12 +2154,6 @@ TclProcCleanupProc( ckfree(localPtr); localPtr = nextPtr; } - /* - * TclOOMethod.c:clOOMakeProcMethod sets cmdPtr to NULL - */ - if (procPtr->cmdPtr) { - TclCleanupCommandMacro(procPtr->cmdPtr); - } ckfree(procPtr); /* diff --git a/tests/interp.test b/tests/interp.test index 9287756..599ac08 100644 --- a/tests/interp.test +++ b/tests/interp.test @@ -3664,43 +3664,6 @@ test interp-38.8 {interp debug basic setup} -body { } -returnCodes { error } -result {wrong # args: should be "interp debug path ?-frame ?bool??"} - -test interp-39.0 { - no segmentation fault when a command is deleted -} -body { - variable res {} - - proc p1 args { - return success - } - namespace eval ns1 { - namespace export * - } - interp alias {} [namespace current]::ns1::p2 {} [namespace current]::p1 - namespace eval ns2 { - namespace import [namespace parent]::ns1::p2 - } - proc ondelete {oldname newname op} { - variable res - namespace delete ns1 - catch { - ns1::p2 - } res - } - - trace add command ns2::p2 delete [namespace which ondelete] - rename ns2::p2 {} - rename p1 {} - if { - [string match {*invalid command name*ns1::p2*} $res] - } { - return 1 - } else { - return $res - } -} -cleanup { -} -result 1 - # cleanup unset -nocomplain hidden_cmds -- cgit v0.12