Index: TODO =================================================================== diff -u -r369f3a961a2872804b5f212ae267c2f78872581e -r152c1d303323553b9eb8a0a04459ba952941ae64 --- TODO (.../TODO) (revision 369f3a961a2872804b5f212ae267c2f78872581e) +++ TODO (.../TODO) (revision 152c1d303323553b9eb8a0a04459ba952941ae64) @@ -5879,6 +5879,9 @@ % exit Warning: RefCount for obj 0x7fc98a050890 4 (name ::nx::shell2) > 1 +- don't call tcl eval operations from NsfLog() in phyical destroy round +- extend regression test for shell with tests in [info nameofexecutable] rather than in nxhs + ======================================================================== TODO: Index: generic/nsf.c =================================================================== diff -u -r472a3c5f359bb9b2d0aeadc7937ba2bc6aecdbc9 -r152c1d303323553b9eb8a0a04459ba952941ae64 --- generic/nsf.c (.../nsf.c) (revision 472a3c5f359bb9b2d0aeadc7937ba2bc6aecdbc9) +++ generic/nsf.c (.../nsf.c) (revision 152c1d303323553b9eb8a0a04459ba952941ae64) @@ -606,9 +606,10 @@ nonnull_assert(fmt != NULL); if (requiredLevel >= RUNTIME_STATE(interp)->logSeverity) { - Tcl_DString cmdString, ds; - const char *level; - va_list ap; + int destroyRound = RUNTIME_STATE(interp)->exitHandlerDestroyRound; + Tcl_DString cmdString, ds; + const char *level; + va_list ap; switch (requiredLevel) { case NSF_LOG_DEBUG: level = "Debug"; break; @@ -625,7 +626,16 @@ Tcl_DStringAppendElement(&cmdString, "::nsf::log"); Tcl_DStringAppendElement(&cmdString, level); Tcl_DStringAppendElement(&cmdString, Tcl_DStringValue(&ds)); - NsfDStringEval(interp, &cmdString, "log command", (NSF_EVAL_LOG|NSF_EVAL_NOPROFILE)); + + if (destroyRound != NSF_EXITHANDLER_ON_PHYSICAL_DESTROY) { + NsfDStringEval(interp, &cmdString, "log command", (NSF_EVAL_LOG|NSF_EVAL_NOPROFILE)); + } else { + /* + * On physical destroy, we can't rely on NsfDStringEval() working + * proplerly. + */ + fprintf(stderr, "%s", cmdString.string); + } Tcl_DStringFree(&cmdString); Tcl_DStringFree(&ds); } @@ -31333,12 +31343,13 @@ #endif #if !defined(NDEBUG) - if (unlikely(object->activationCount != 0)) { - fprintf(stderr, "FinalObjectDeletion obj %p activationcount %d\n", - (void *)object, object->activationCount); + if (RUNTIME_STATE(interp)->exitHandlerDestroyRound != NSF_EXITHANDLER_ON_PHYSICAL_DESTROY) { + assert(object->activationCount == 0); + } else if (object->activationCount != 0) { + NsfLog(interp, NSF_LOG_WARN, "FinalObjectDeletion obj %p activationcount %d\n", + (void *)object, object->activationCount); } #endif - assert(object->activationCount == 0); if (likely(object->id != NULL)) { /*fprintf(stderr, " ... cmd dealloc %p final delete refCount %d\n", Index: tests/shells.test =================================================================== diff -u -r31727ed145eba8f7d81bc93fc0a9ee47c6096b7c -r152c1d303323553b9eb8a0a04459ba952941ae64 --- tests/shells.test (.../shells.test) (revision 31727ed145eba8f7d81bc93fc0a9ee47c6096b7c) +++ tests/shells.test (.../shells.test) (revision 152c1d303323553b9eb8a0a04459ba952941ae64) @@ -47,14 +47,25 @@ file delete -force $tmpfile # exit and exit codes + + ? [list exec [info nameofexecutable] << "exit 0"] "" + ? [list exec [info nameofexecutable] << "exit 1"] "child process exited abnormally" + + ? [list exec [info nameofexecutable] << "package req nx;exit 0"] "" + ? [list exec [info nameofexecutable] << "package req nx;exit 1"] "child process exited abnormally" + ? [list exec $nxsh -c "exit 0"] "" ? [list exec $nxsh -c "exit 1"] "child process exited abnormally" ? [list exec $nxsh -c "exit 2"] "child process exited abnormally" ? [list exec $nxsh -c "exit 5"] "child process exited abnormally" + ? [list catch [list exec $nxsh -c "exit 5"] ::res ::opts] "1" + ? [list catch [list exec $nxsh -c "exit 5"] ::res ::opts] "0" ? {set ::res} "child process exited abnormally" + ? {set ::res} "" ? {lindex [dict get $::opts -errorcode] end} "5" unset ::res; unset ::opts + ? [list exec $nxsh -c << "exit 0"] "" ? [list exec $nxsh -c << "exit 1"] "child process exited abnormally" ? [list exec $nxsh -c << "catch {exit 1}"] "child process exited abnormally" @@ -67,6 +78,8 @@ ## ? [list expr [list [lsort $gvars1] eq [lsort $gvars2]]] 1 } + +puts exec=[info nameofexecutable] # Local variables: # mode: tcl # tcl-indent-level: 2