Tcl Source Code

View Ticket
Login
Ticket UUID: 1566526
Title: TclTeardownNamespace segfault (nspath related)
Type: Bug Version: obsolete: 8.5a5
Submitter: dgp Created on: 2006-09-27 17:51:45
Subsystem: 21. [namespace] Assigned To: dgp
Priority: 7 High Severity:
Status: Closed Last Modified: 2006-10-10 23:45:14
Resolution: Fixed Closed By: dgp
    Closed on: 2006-10-10 16:45:14
Description:
The snit test suite (in tcllib)
is used to demo this one:

$ make gdb
...
(gdb) run
Starting program: /path/to/tcl/debug/./tclsh 
% set argv {-modules snit}
-modules snit
% set argc [llength $argv]
2
% source /path/to/tcllib-1.9/support/devel/all.tcl
...
@@ Tcl 8.5a5
@@ MatchTests *
@@ SkipFiles l.*.test
@@ MatchFiles *.test
@@ Start 1159379334
@@ Module snit
@@ Testsuite modules/snit/snit.test
- tcllib::testutils 1.1
* snit 2.1
---- Expand-1.1 start
++++ Expand-1.1 PASSED
...
++++ bug-3.1 SKIPPED: tk

Program received signal SIGSEGV, Segmentation fault.
0x2000022bc20 in TclTeardownNamespace (nsPtr=0x120237608)
    at /local/src/tcl/unix/../generic/tclNamesp.c:1112
1112                nsPathPtr->nsPtr = NULL;


Stack trace:

#0  0x2000022bc20 in TclTeardownNamespace
(nsPtr=0x120237608)
    at /local/src/tcl/unix/../generic/tclNamesp.c:1112
#1  0x2000022b9b4 in Tcl_DeleteNamespace
(namespacePtr=0x120237608)
    at /local/src/tcl/unix/../generic/tclNamesp.c:992
#2  0x2000016daa4 in DeleteInterpProc (interp=0x120238308)
    at /local/src/tcl/unix/../generic/tclBasic.c:1056
#3  0x2000024f438 in Tcl_EventuallyFree
(clientData=0x120238308, 
    freeProc=0x2000016d7e0 <DeleteInterpProc>)
    at /local/src/tcl/unix/../generic/tclPreserve.c:312
#4  0x2000016d7ac in Tcl_DeleteInterp (interp=0x120238308)
    at /local/src/tcl/unix/../generic/tclBasic.c:934
#5  0x200002011d0 in SlaveObjCmdDeleteProc
(clientData=0x120238308)
    at /local/src/tcl/unix/../generic/tclInterp.c:2412
#6  0x2000016f9dc in Tcl_DeleteCommandFromToken
(interp=0x120107438, 
    cmd=0x120256098) at
/local/src/tcl/unix/../generic/tclBasic.c:2534
#7  0x200001fdad0 in Tcl_InterpObjCmd (clientData=0x0,
interp=0x120107438, 
    objc=3, objv=0x1201084e0) at
/local/src/tcl/unix/../generic/tclInterp.c:724
#8  0x200001712c4 in TclEvalObjvInternal
(interp=0x120107438, objc=3, 
    objv=0x1201084e0, command=0x0, length=0, flags=0)
    at /local/src/tcl/unix/../generic/tclBasic.c:3383
#9  0x200001d6914 in TclExecuteByteCode
(interp=0x120107438, 
    codePtr=0x120236cb8) at
/local/src/tcl/unix/../generic/tclExecute.c:1795
#10 0x200001d37e8 in TclCompEvalObj
(interp=0x120107438, objPtr=0x1201793b8)
    at /local/src/tcl/unix/../generic/tclExecute.c:1003
#11 0x200001726d0 in Tcl_EvalObjEx (interp=0x120107438,
objPtr=0x1201793b8, 
    flags=0) at
/local/src/tcl/unix/../generic/tclBasic.c:4060
#12 0x200001844f0 in Tcl_ForeachObjCmd (dummy=0x0,
interp=0x120107438, objc=4, 
    objv=0x11fffe970) at
/local/src/tcl/unix/../generic/tclCmdAH.c:1816
#13 0x200001712c4 in TclEvalObjvInternal
(interp=0x120107438, objc=4, 
    objv=0x11fffe970, 
    command=0x12017764d "foreach module $modules {\n  
 set ::tcltest::testsDirectory [file join $root modules
$module]\n\n    if { ![file isdirectory
$::tcltest::testsDirectory] } {\n\tputs stdout
\"unknown module $module\"\n    }\n\n"..., length=1983,
flags=0) at /local/src/tcl/unix/../generic/tclBasic.c:3383
#14 0x20000171ffc in Tcl_EvalEx (interp=0x120107438, 
    script=0x1201766e8 "# all.tcl --\n#\n# This file
contains a top-level script to run all of the Tcl\n#
tests.  Execute it by invoking \"tclsh all.test\" in
this directory.\n#\n# To test a subset of the modules,
invoke it by 'tcl"..., 
    numBytes=6192, flags=0) at
/local/src/tcl/unix/../generic/tclBasic.c:3790
#15 0x2000021d9fc in Tcl_FSEvalFileEx (interp=0x120107438, 
    pathPtr=0x12016acd8, encodingName=0x0)
    at /local/src/tcl/unix/../generic/tclIOUtil.c:1809
#16 0x2000018f904 in Tcl_SourceObjCmd (dummy=0x0,
interp=0x120107438, objc=2, 
    objv=0x1201084d0) at
/local/src/tcl/unix/../generic/tclCmdMZ.c:959
#17 0x200001712c4 in TclEvalObjvInternal
(interp=0x120107438, objc=2, 
    objv=0x1201084d0, command=0x0, length=0, flags=0)
    at /local/src/tcl/unix/../generic/tclBasic.c:3383
#18 0x200001d6914 in TclExecuteByteCode
(interp=0x120107438, 
    codePtr=0x12012c8c8) at
/local/src/tcl/unix/../generic/tclExecute.c:1795
#19 0x200001d37e8 in TclCompEvalObj
(interp=0x120107438, objPtr=0x1201259a8)
    at /local/src/tcl/unix/../generic/tclExecute.c:1003
#20 0x200001726d0 in Tcl_EvalObjEx (interp=0x120107438,
objPtr=0x1201259a8, 
    flags=131072) at
/local/src/tcl/unix/../generic/tclBasic.c:4060
#21 0x200001fc220 in Tcl_RecordAndEvalObj
(interp=0x120107438, 
    cmdPtr=0x1201259a8, flags=131072)
    at /local/src/tcl/unix/../generic/tclHistory.c:146
#22 0x20000229ee4 in Tcl_Main (argc=-1, argv=0x11ffff440, 
    appInitProc=0x120000900 <Tcl_AppInit>)
    at /local/src/tcl/unix/../generic/tclMain.c:546
#23 0x1200008dc in main (argc=1, argv=0x11ffff438)
    at /local/src/tcl/unix/../unix/tclAppInit.c:87
User Comments: dgp added on 2006-10-10 23:45:14:
Logged In: YES 
user_id=80530


fix committed

dgp added on 2006-10-05 00:00:35:
Logged In: YES 
user_id=80530


This ought to be simple enough
demo script to work with:

interp create slave
slave eval namespace eval demo namespace path ::
interp delete slave

dgp added on 2006-10-04 23:17:13:
Logged In: YES 
user_id=80530


Here's a much smaller
demo script:

interp create slave
slave eval {
    package require snit 2.1
    snit::type dummy {
        destructor {}
        constructor {args} {
            $self configurelist $args
        }
    }
    rename ::dummy ""
}
interp delete slave

dkf added on 2006-09-28 03:43:35:
Logged In: YES 
user_id=79902

I cannot reproduce this bug. Given the complexity of the
problem (and the fact that it is supposed to work) I will
not attempt to fix this without a Tcl test that exhibits the
problem. Only then will I be able to test that my ideas on a
fix will actually work.

msofer added on 2006-09-28 02:31:34:
Logged In: YES 
user_id=148712

I cannot repro here; gathering info from other sources:

(1) Don reports that *(nsPtr->commandPathSourceList) is
freed memory

(2) aku's attached valgrind says that there RW to memory
previously freed by UnlinkNSPath

andreas_kupries added on 2006-09-28 01:11:29:

File Added - 195524: SNIT.gz

Logged In: YES 
user_id=75003

Why is nobody attaching these long traces, but inlining them ?
Ok, attached the output of the tcllib testsuite, at the
bottom you can see valgrind reporting trouble in TearDownNS.

Attachments: