Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Crash from ensemble handling

Closed / Fixedcea0344a510723862ec46c632e4262042ea12c6eCreated 10 years agoUpdated 10 years ago
Descriptionwiki2016-07-10 07:32:38
I was working on sorting out [3606121], and hit a critical bug (while looking at test namespace-17.5; I will apply a workaround for that as the failing path isn't supposed to be taken in that test either). The following code will crash:
    namespace eval ::test_ns_1 {
        catch {namespace delete test_ns_2}
        namespace eval test_ns_3 {
            variable ::test_ns_1::test_ns_2::x 2222
        }
    }
When debugging, it looks like the crash is due to the number of arguments being recorded wrongly in the stack frame; the actual crash comes out of TclLogCommandInfo, but is because the frame's argv has four valid elements in it, but argc is 5. It looks like TclFetchEnsembleRoot (called from NRNamespaceEvalCmd) is doing something wrong, which means there's a problem, and that code isn't something I've worked with.
dkf Ticket [cea0344a51]: 5 changes [History diff]2016-07-10 07:33:11
dgpplain2016-07-10 14:35:11
On the core-8-6-branch tip [b6a05c2ceb] with
--disable-shared --enable-symbols=all I get

%  namespace eval ::test_ns_1 {
        catch {namespace delete test_ns_2}
        namespace eval test_ns_3 {
            variable ::test_ns_1::test_ns_2::x 2222
        }
    }
can't define "::test_ns_1::test_ns_2::x": parent namespace doesn't exist

Not a crash, just an error.

Any other details?
dkfwiki2016-07-10 22:45:01

Hmm, the crash occurred for me when I was running just that test on its own, but it seems sensitive to what context it is called from. This crashed for me in a plain interactive shell:

$ make shell
[…]
% namespace eval foo { namespace eval bar { namespace delete foo } }
Trying to incr ref count of Tcl_Obj allocated in another thread
make: *** [shell] Abort trap: 6
And yes, I've also seen the wrong error messages popping up. I've no idea what's wrong, but we definitely can't release 8.6.6 in this state, where error messages inside namespace eval cause weird things to happen.

dgpplain2016-07-11 15:54:19
That example also Works For Me:

% namespace eval foo {namespace eval bar { namespace delete foo } }
unknown namespace "foo" in namespace delete command

Result appears correct.
dkfwiki2016-07-11 18:16:34

That's weird. I'm trying exactly with 8.6 tip in --enable-symbols=mem, and I just get this (cut-n-paste from my terminal):

cspool92:unix dkf$ make shell
Warning: tclOOStubInit.c may be out of date.
Developers may want to run "make genstubs" to regenerate.
This warning can be safely ignored, do not report as a bug!
DYLD_LIBRARY_PATH=`pwd`: TCLLIBPATH="/Users/dkf/Documents/software/tcl8.6/unix/pkgs" TCL_LIBRARY="/Users/dkf/Documents/software/tcl8.6/library" ./tclsh 
% namespace eval foo {namespace eval bar { namespace delete foo } }
Trying to incr ref count of Tcl_Obj allocated in another thread
make: *** [shell] Abort trap: 6
cspool92:unix dkf$ head config.log 
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by tcl configure 8.6, which was
generated by GNU Autoconf 2.59.  Invocation command line was

  $ ./configure --enable-symbols=mem

## --------- ##
## Platform. ##
cspool92:unix dkf$ gcc --version
gcc (MacPorts gcc5 5.3.0_1) 5.3.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I really hope that the compiler version isn't significant!

dgpplain2016-07-11 20:02:44
That was the clue I needed.   Reproduced.  Will pursue.
dgpplain2016-07-11 21:57:11
Fix committed.
Log in (anonymous is fine) to add a comment.