Index: generic/nsf.c =================================================================== diff -u -N -rc9a0d623d5d561d4c0f1dcd97cada90ba8fbb108 -rc4dd42ea5b714013b9d1d7a71ae2c895dc322ef8 --- generic/nsf.c (.../nsf.c) (revision c9a0d623d5d561d4c0f1dcd97cada90ba8fbb108) +++ generic/nsf.c (.../nsf.c) (revision c4dd42ea5b714013b9d1d7a71ae2c895dc322ef8) @@ -18639,13 +18639,6 @@ DECR_REF_COUNT2("procNameObj", tcd->procName); if (tcd->cmd != NULL) { - /* - * Re-wire the original namespace into the shadowed cmd, to prevent - * namespace references from becoming dangling and to keep the involved - * namespaces' refcount books balanced. - */ - ((Command *)tcd->cmd)->nsPtr = (Namespace *)tcd->origNsPtr; - NSNamespaceRelease(tcd->origNsPtr); NsfCommandRelease(tcd->cmd); } /* tcd->paramDefs is freed by NsfProcDeleteProc() */ @@ -18668,12 +18661,14 @@ *---------------------------------------------------------------------- */ static int InvokeShadowedProc(Tcl_Interp *interp, Tcl_Obj *procNameObj, Tcl_Command cmd, ParseContext *pcPtr, - struct Tcl_Time *trtPtr, unsigned int cmdFlags) - nonnull(1) nonnull(2) nonnull(4) nonnull(3) nonnull(4); + struct Tcl_Time *trtPtr, unsigned int cmdFlags, + Tcl_Namespace *execNsPtr) + nonnull(1) nonnull(2) nonnull(4) nonnull(3) nonnull(4) nonnull(5); static int InvokeShadowedProc(Tcl_Interp *interp, Tcl_Obj *procNameObj, Tcl_Command cmd, ParseContext *pcPtr, - struct Tcl_Time *trtPtr, unsigned int cmdFlags) { + struct Tcl_Time *trtPtr, unsigned int cmdFlags, + Tcl_Namespace *execNsPtr) { Tcl_Obj *const *objv; int objc, result, includeTiming; const char *fullMethodName; @@ -18728,12 +18723,13 @@ procPtr = (Proc *)Tcl_Command_objClientData(cmd); result = TclPushStackFrame(interp, &framePtr, - (Tcl_Namespace *) procPtr->cmdPtr->nsPtr, + execNsPtr /* procPtr->cmdPtr->nsPtr */, (FRAME_IS_PROC)); if (likely(result == TCL_OK)) { unsigned int dummy = 0; - result = ByteCompiled(interp, &dummy, procPtr, procPtr->cmdPtr->nsPtr, fullMethodName); + result = ByteCompiled(interp, &dummy, procPtr, (Namespace *)execNsPtr, + fullMethodName); } if (unlikely(result != TCL_OK)) { /* todo: really? error msg? */ @@ -18876,7 +18872,8 @@ NsfDeprecatedCmd(interp, "proc", ObjStr(objv[0]), ""); } - result = InvokeShadowedProc(interp, tcd->procName, tcd->cmd, pcPtr, &trt, cmdFlags); + result = InvokeShadowedProc(interp, tcd->procName, tcd->cmd, pcPtr, &trt, + cmdFlags, Tcl_Command_nsPtr(cmd)); } else { /* @@ -19075,13 +19072,7 @@ Tcl_Command procCmd = Tcl_GetCommandFromObj(interp, procNameObj); assert(procCmd != NULL); - /* - * Preserve the shadowed cmd's original namespace (::nsf::procs::*) for - * later re-wiring in NsfProcStubDeleteProc() - */ - tcd->origNsPtr = Tcl_Command_nsPtr(procCmd); - NSNamespacePreserve(tcd->origNsPtr); - ((Command *)procCmd)->nsPtr = (Namespace *)cmdNsPtr; + tcd->cmd = procCmd; NsfCommandPreserve(tcd->cmd);