Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: b70eadd96a0167a8e2565d1ef251c1681c0f099f
Ticket: 2415422fffffffffffffffffffffffffffffffff
TclExecuteByteCode assert fail after {*}longlist
User & Date: andygoth on 2008-12-11 01:06:44
Changes

  1. assignee changed to: "msofer"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    The following code
    
    proc nop {} {}
    proc crash {} {
        foreach val [list {*}[lrepeat 1781 x]] {
            nop
        }
    }
    crash
    
    results in an assertion failure:
    
    tclsh: /home/users/td26063/build/tcl8.6a3/unix/../generic/tclExecute.c:2047: TclExecuteByteCode: Assertion `(((Interp *) interp)->cmdFramePtr == bcFramePtr)' failed.
    
    with backtrace:
    
    #0  0x0048d7a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
    #1  0x00128825 in raise () from /lib/tls/libc.so.6
    #2  0x0012a289 in abort () from /lib/tls/libc.so.6
    #3  0x00121da1 in __assert_fail () from /lib/tls/libc.so.6
    #4  0x00885756 in TclExecuteByteCode (interp=0x80688e0, codePtr=0x808c230)
        at /home/users/td26063/build/tcl8.6a3/unix/../generic/tclExecute.c:2047
    #5  0x0082fa2c in NRCallTEBC (data=0x807dd2c, interp=0x80688e0, result=0)
        at /home/users/td26063/build/tcl8.6a3/unix/../generic/tclBasic.c:4292
    #6  0x0082f789 in TclNRRunCallbacks (interp=0x80688e0, result=0, rootPtr=0x0,
        tebcCall=0)
        at /home/users/td26063/build/tcl8.6a3/unix/../generic/tclBasic.c:4208
    #7  0x0082f3de in Tcl_EvalObjv (interp=0x80688e0, objc=1, objv=0x80691b0,
        flags=2097152)
        at /home/users/td26063/build/tcl8.6a3/unix/../generic/tclBasic.c:3991
    #8  0x00830dd3 in TclEvalEx (interp=0x80688e0,
        script=0x8080960 "proc nop {} {}\nproc crash {} {\n    foreach val [list {*}[lrepeat 1781 x]] {\n        nop\n    }\n}\ncrash\n", numBytes=102, flags=0,
        line=7)
        at /home/users/td26063/build/tcl8.6a3/unix/../generic/tclBasic.c:5085
    #9  0x0083050e in Tcl_EvalEx (interp=0x80688e0,
        script=0x8080960 "proc nop {} {}\nproc crash {} {\n    foreach val [list {*}[lrepeat 1781 x]] {\n        nop\n    }\n}\ncrash\n", numBytes=102, flags=0)
        at /home/users/td26063/build/tcl8.6a3/unix/../generic/tclBasic.c:4786
    #10 0x008b81f0 in Tcl_FSEvalFileEx (interp=0x80688e0, pathPtr=0x807e4c0,
        encodingName=0x0)
        at /home/users/td26063/build/tcl8.6a3/unix/../generic/tclIOUtil.c:1757
    #11 0x008c03a6 in Tcl_Main (argc=-1, argv=0xbfe96a2c,
        appInitProc=0x804868b <Tcl_AppInit>)
        at /home/users/td26063/build/tcl8.6a3/unix/../generic/tclMain.c:442
    #12 0x0804867e in main (argc=2, argv=0xbfe96a24)
        at /home/users/td26063/build/tcl8.6a3/unix/../unix/tclAppInit.c:87
    
    Tcl doesn't crash when the repeat count is reduced to 1780 or less.  Tcl DOES crash when "x" is replaced with "", so the string length doesn't seem to have anything to do with it.
    
    Tcl doesn't crash when nop's definition is changed to "proc nop {args} {}", since the bytecode compiler optimizes that to a true no-op.  Tcl also doesn't crash when nop is removed from the loop, even if it is replaced with "puts moo" or any other combination of command (not proc!) invocations.
    
    Tcl doesn't crash when the loop is changed to "foreach val [lrepeat 1781 x] {nop}", so it is critical that {*} expansion take place.
    
    Tcl doesn't crash when the loop is replaced with some other structure, for example:
    
    proc nop {} {return 1}
    proc crash {} {
        if {[llength [list {*}[lrepeat 1781 ""]]]} {
            nop
        }
    }
    crash
    
    so it appears that [foreach] also has a hand in this.  Tcl DOES crash when additional control structures are put around the call to nop, for example:
    
    proc nop {} {}
    proc crash {} {
        foreach val [list {*}[lrepeat 1781 ""]] {
            foreach foo {1 2 3} {nop}
        }
    }
    crash
    
    The number 1781 may be magic only for my particular computer and architecture.  Here's the output of uname -a:
    
    Linux ARL020474LX 2.6.9-78.0.5.ELsmp #1 SMP Wed Oct 8 07:12:03 EDT 2008 i686 i686 i386 GNU/Linux
    
    The system has two 2.8GHz Pentium 4 CPUs and one gigabyte of RAM.
    
  4. foundin changed to: "obsolete: 8.6a3"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "andygoth"
  10. subsystem changed to: "45. Parsing and Eval"
  11. title changed to: "TclExecuteByteCode assert fail after {*}longlist"
  12. type changed to: "Bug"