Tcl Source Code

View Ticket
Login
Ticket UUID: 3412487
Title: Crash in [chan copy]
Type: Bug Version: obsolete: 8.6b2
Submitter: egavilan Created on: 2011-09-21 18:33:46
Subsystem: 25. Channel System Assigned To: ferrieux
Priority: 9 Immediate Severity:
Status: Closed Last Modified: 2011-09-22 03:56:02
Resolution: Fixed Closed By: ferrieux
    Closed on: 2011-09-21 20:56:02
Description:
** Firing script is (works with any file)
====================================================================
set fdin [open output.dat]
set fdout [open out2.dat w]
chan copy $fdin $fdout
vwait foo
====================================================================

** Replacing the last two lines for the following does not fire the bug
   in either case
====================================================================
chan copy $fdin $fdout -command {set foo} ;# added -command
vwait foo
====================================================================
====================================================================
chan copy $fdin $fdout ;# removed [vwait]
====================================================================

** gdb output is (netbsd amd-64)
emiliano@beaujolais:~/src/fossil/sunaudio$ gdb tclsh8.6 -core tclsh8.6.core 
GNU gdb 6.5
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64--netbsd"...
Reading symbols from /usr/local/lib/libtcl8.6.so...done.
Loaded symbols for /usr/local/lib/libtcl8.6.so
Reading symbols from /usr/lib/libz.so.1...done.
Loaded symbols for /usr/lib/libz.so.1
Reading symbols from /usr/lib/libpthread.so.1...done.
Loaded symbols for /usr/lib/libpthread.so.1
Reading symbols from /usr/lib/libm.so.0...done.
Loaded symbols for /usr/lib/libm.so.0
Reading symbols from /usr/lib/libc.so.12...done.
Loaded symbols for /usr/lib/libc.so.12
Reading symbols from /usr/libexec/ld.elf_so...done.
Loaded symbols for /usr/libexec/ld.elf_so
Core was generated by `tclsh8.6'.
Program terminated with signal 11, Segmentation fault.
#0  0x00007f7ff78edbdb in CopyData (csPtr=0x7f7ff730d038, mask=2)
    at /home/emiliano/src/fossil/tcl/generic/tclIO.c:9111
9111        inStatePtr  = csPtr->readPtr->state;
(gdb) bt full
#0  0x00007f7ff78edbdb in CopyData (csPtr=0x7f7ff730d038, mask=2)
    at /home/emiliano/src/fossil/tcl/generic/tclIO.c:9111
        interp = (Tcl_Interp *) 0x7f7fffffd3d0
        cmdPtr = (Tcl_Obj *) 0x7f7ff77010b0
        errObj = (Tcl_Obj *) 0x0
        bufObj = (Tcl_Obj *) 0x0
        msg = (Tcl_Obj *) 0x0
        inChan = (Tcl_Channel) 0x6161616161616161
        outChan = (Tcl_Channel) 0x6161616161616161
        inStatePtr = (ChannelState *) 0x7f7fffffd390
        outStatePtr = (ChannelState *) 0x7f7ff77010b0
        result = 0
        size = -142794184
        sizeb = 0
        total = 28853812
        buffer = 0x1f770c738 <Address 0x1f770c738 out of bounds>
        inBinary = 0
        outBinary = 578
        sameEncoding = 32639
        underflow = 32639
#1  0x00007f7ff78eefc1 in CopyEventProc (clientData=0x7f7ff730d038, mask=2)
    at /home/emiliano/src/fossil/tcl/generic/tclIO.c:9968
No locals.
#2  0x00007f7ff78ecdf0 in Tcl_NotifyChannel (channel=0x7f7ff7313ab8, mask=2)
    at /home/emiliano/src/fossil/tcl/generic/tclIO.c:8281
        chanPtr = (Channel *) 0x7f7ff7313ab8
        statePtr = (ChannelState *) 0x7f7ff772b3f8
        chPtr = (ChannelHandler *) 0x7f7ff7302858
        tsdPtr = (ThreadSpecificData *) 0x7f7ff7714218
        nh = {nextHandlerPtr = 0x0, nestedHandlerPtr = 0x0}
        upChanPtr = (Channel *) 0x7f7ff7936057
        upTypePtr = (const Tcl_ChannelType *) 0x7f7fffffd430
#3  0x00007f7ff79627ff in FileHandlerEventProc (evPtr=0x7f7ff73157d8, flags=-3)
    at /home/emiliano/src/fossil/tcl/unix/tclUnixNotfy.c:652
        mask = 2
        filePtr = (FileHandler *) 0x7f7ff73028c8
        fileEvPtr = (FileHandlerEvent *) 0x7f7ff73157d8
        tsdPtr = (ThreadSpecificData *) 0x7f7ff772b178
#4  0x00007f7ff790f00e in Tcl_ServiceEvent (flags=-3) at /home/emiliano/src/fossil/tcl/generic/tclNotify.c:670
        evPtr = (Tcl_Event *) 0x7f7ff73157d8
        prevPtr = (Tcl_Event *) 0x246
        proc = (Tcl_EventProc *) 0x7f7ff7962755 <FileHandlerEventProc>
        result = 0
        tsdPtr = (ThreadSpecificData *) 0x7f7ff7717178
#5  0x00007f7ff790f473 in Tcl_DoOneEvent (flags=-3) at /home/emiliano/src/fossil/tcl/generic/tclNotify.c:971
        result = 0
        oldMode = 0
        sourcePtr = (EventSource *) 0x0
        timePtr = (Tcl_Time *) 0x0
        tsdPtr = (ThreadSpecificData *) 0x7f7ff7717178
#6  0x00007f7ff78c1587 in Tcl_VwaitObjCmd (clientData=0x0, interp=0x7f7ff7730838, objc=2, objv=0x7f7ff7740320)
    at /home/emiliano/src/fossil/tcl/generic/tclEvent.c:1413
        done = 0
        foundEvent = 1
        nameString = 0x7f7ff77b27c8 "foo"
#7  0x00007f7ff783fcb8 in TclNREvalObjv (interp=0x7f7ff7730838, objc=2, objv=0x7f7ff7740320, flags=2097152, 
    cmdPtr=0x7f7ff7746db8) at /home/emiliano/src/fossil/tcl/generic/tclBasic.c:4273
        iPtr = (Interp *) 0x7f7ff7730838
        result = 0
        lookupNsPtr = (Namespace *) 0x0
        cmdPtrPtr = (Command **) 0x7f7ff73137c0
#8  0x00007f7ff783f745 in Tcl_EvalObjv (interp=0x7f7ff7730838, objc=2, objv=0x7f7ff7740320, flags=2097152)
    at /home/emiliano/src/fossil/tcl/generic/tclBasic.c:4106
        result = 32639
        rootPtr = (NRE_callback *) 0x0
#9  0x00007f7ff7841ad3 in TclEvalEx (interp=0x7f7ff7730838, 
    script=0x7f7ff77174e8 "set fdin [open output.dat]\nset fdout [open out2.dat w]\n\nchan copy $fdin $fdout\nvwait foo", numBytes=88, flags=0, line=5, clNextOuter=0x0, 
    outerScript=0x7f7ff77174e8 "set fdin [open output.dat]\nset fdout [open out2.dat w]\n\nchan copy $fdin $fdout\nvwait foo") at /home/emiliano/src/fossil/tcl/generic/tclBasic.c:5213
        wordLine = 5
        wordCLNext = (int *) 0x0
        objectsNeeded = 2
        wordStart = 0x7f7ff771753d "foo"
        numWords = 2
        iPtr = (Interp *) 0x7f7ff7730838
        p = 0x7f7ff7717537 "vwait foo"
        next = 0x7f7ff7717537 "vwait foo"
        minObjs = 20
        objv = (Tcl_Obj **) 0x7f7ff7740320
        objvSpace = (Tcl_Obj **) 0x7f7ff7740320
        expand = (int *) 0x7f7ff77403d0
        lines = (int *) 0x7f7ff7740430
        lineSpace = (int *) 0x7f7ff7740430
        tokenPtr = (Tcl_Token *) 0x7f7ff7740130
        commandLength = 4
        bytesLeft = 9
        expandRequested = 0
        code = 0
        savedVarFramePtr = (CallFrame *) 0x7f7ff7717228
        allowExceptions = 0
        gotParse = 1
        i = 4
        objectsUsed = 2
        parsePtr = (Tcl_Parse *) 0x7f7ff7740070
        eeFramePtr = (CmdFrame *) 0x7f7ff77402c0
        stackObjArray = (Tcl_Obj **) 0x7f7ff7740320
        expandStack = (int *) 0x7f7ff77403d0
        linesStack = (int *) 0x7f7ff7740430
        clNext = (int *) 0x0
#10 0x00007f7ff7840ec5 in Tcl_EvalEx (interp=0x7f7ff7730838, 
    script=0x7f7ff77174e8 "set fdin [open output.dat]\nset fdout [open out2.dat w]\n\nchan copy $fdin $fdout\nvwait foo", numBytes=88, flags=0) at /home/emiliano/src/fossil/tcl/generic/tclBasic.c:4871
No locals.
#11 0x00007f7ff78fdea5 in Tcl_FSEvalFileEx (interp=0x7f7ff7730838, pathPtr=0x7f7ff77d1c38, encodingName=0x0)
    at /home/emiliano/src/fossil/tcl/generic/tclIOUtil.c:1751
        length = 88
        result = 1
        statBuf = {st_dev = 0, st_mode = 33188, st_ino = 2320585, st_nlink = 1, st_uid = 1000, st_gid = 100, 
  st_rdev = 9572511, st_atimespec = {tv_sec = 1316624800, tv_nsec = 748385059}, st_mtimespec = {tv_sec = 1316624776, 
    tv_nsec = 250287675}, st_ctimespec = {tv_sec = 1316624776, tv_nsec = 250287675}, st_birthtimespec = {
    tv_sec = 1316624750, tv_nsec = 638348727}, st_size = 88, st_blocks = 4, st_blksize = 16384, st_flags = 0, 
  st_gen = 0, st_spare = {0, 0}}
        oldScriptFile = (Tcl_Obj *) 0x0
        iPtr = (Interp *) 0x7f7ff7730838
        string = 0x7f7ff77174e8 "set fdin [open output.dat]\nset fdout [open out2.dat w]\n\nchan copy $fdin $fdout\nvwait foo"
        chan = (Tcl_Channel) 0x7f7ff73133b8
        objPtr = (Tcl_Obj *) 0x7f7ff73135b8
#12 0x00007f7ff790784f in Tcl_MainEx (argc=-1, argv=0x7f7fffffdad8, appInitProc=0x400a8e <Tcl_AppInit>, 
    interp=0x7f7ff7730838) at /home/emiliano/src/fossil/tcl/generic/tclMain.c:407
        path = (Tcl_Obj *) 0x7f7ff77d1c38
        resultPtr = (Tcl_Obj *) 0x7f7ff773c438
        argvPtr = (Tcl_Obj *) 0x7f7ff77d2038
        appName = (Tcl_Obj *) 0x7f7ff77d1c38
        encodingName = 0x0
        code = 0
        exitCode = 0
        mainLoopProc = (Tcl_MainLoopProc *) 0x7f7ff77a5cf8
        chan = (Tcl_Channel) 0x7f7ff7717228
        is = {input = 0x6d3a3a6c63743a3a, tty = 1, commandPtr = 0x7f7ff77d1bb8, prompt = PROMPT_START, 
  interp = 0x7f7ff7730838}
#13 0x00007f7ff7907fcf in Tcl_Main (argc=2, argv=0x7f7fffffdac8, appInitProc=0x400a8e <Tcl_AppInit>)
    at /home/emiliano/src/fossil/tcl/generic/tclMain.c:634
No locals.
#14 0x0000000000400a87 in main (argc=2, argv=0x7f7fffffdac8) at /home/emiliano/src/fossil/tcl/unix/tclAppInit.c:84
No locals.

** bug appears on commit http://core.tcl.tk/tcl/info/2b3b49886d80429a62d1

** reproducible on both linux 32 bits and netbsd 64 bits.
User Comments: ferrieux added on 2011-09-22 03:56:02:
OK:
Before the advent of short-reads-in-sync-fcopy, the test
   underflow && !Tcl_Eof(inChan)
implied that it inChan was nonblocking and hence the fcopy was async.
It is no longer the case, so just add "cmdPtr &&".
Refactoring the test makes it just as concise.
Fixed in trunk.

egavilan added on 2011-09-22 01:33:47:

File Added - 424173: ktruss.out

Attachments: