Skip to content
Tcl Source Code History Of Ticket 2415422
Login

History Of Ticket 2415422

Artifacts Associated With Ticket 2415422

  1. Ticket change [b70eadd96a] (rid 125522) by andygoth on 2008-12-11 01:06:44:

    1. assignee initialized to: "msofer"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized 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 initialized to: "obsolete: 8.6a3"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "andygoth"
    10. subsystem initialized to: "45. Parsing and Eval"
    11. title initialized to: "TclExecuteByteCode assert fail after {*}longlist"
    12. type initialized to: "Bug"
  2. Ticket change [c2c5eb0d1c] (rid 111540) by msofer on 2008-12-11 08:24:55:

    1. priority changed to: "9 Immediate"
  3. Ticket change [7a09650db4] (rid 90237) by ferrieux on 2008-12-11 23:58:43:

    1. icomment:
      Hum, cannot repro on:
      Linux lat6466.rd.francetelecom.fr 2.6.9-67.0.22.ELsmp #1 SMP Wed Jul 23 17:30:51 EDT 2008 i686 i686 i386 GNU/Linux
      
      I tried both CFLAGS_DEBUG and CFLAGS_OPTIMIZE.
      Here is the disassembled [crash]:
      
      % ::tcl::unsupported::dis proc crash
      ByteCode 0x0x9ff9060, refCt 1, epoch 4, interp 0x0x9fdf0f0 (epoch 4)
        Source "\n   if {[llength [list {*}[lrepeat 1781 \"\"]]]} {\n      "
        Cmds 5, src 65, inst 30, litObjs 5, aux 0, stkDepth 4, code/src 0.00
        Proc 0x0xa011058, refCt 1, args 0, compiled locals 0
        Commands 5:
            1: pc 0-28, src 4-63         2: pc 0-17, src 9-43
            3: pc 0-16, src 18-42        4: pc 3-10, src 27-41
            5: pc 21-24, src 56-58
        Command 1: "if {[llength [list {*}[lrepeat 1781 \"\"]]]} {\n       nop"
        Command 2: "llength [list {*}[lrepeat 1781 \"\"]]"
        Command 3: "list {*}[lrepeat 1781 \"\"]"
          (0) expandStart 
          (1) push1 0         # "list"
        Command 4: "lrepeat 1781 \"\""
          (3) push1 1         # "lrepeat"
          (5) push1 2         # "1781"
          (7) push1 3         # ""
          (9) invokeStk1 3 
          (11) expandStkTop 2 
          (16) invokeExpanded 
          (17) listLength 
          (18) tryCvtToNumeric 
          (19) jumpFalse1 +8  # pc 27
        Command 5: "nop"
          (21) push1 4        # "nop"
          (23) invokeStk1 1 
          (25) jump1 +4       # pc 29
          (27) push1 3        # ""
          (29) done 
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  4. Ticket change [b20f58f37b] (rid 98269) by ferrieux on 2008-12-12 06:48:06:

    1. icomment:
      FWIW, I found that the above code takes higher values to crash when typed interactively, but crashes for the critical value 1781 when sourced.
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  5. Ticket change [0400987331] (rid 119919) by ferrieux on 2008-12-12 19:54:24:

    1. icomment:
      I did a twin-gdb-session with one crashing an one non-crashing values.
      The divergence occurs on return from GrowEvaluationStack at tclExecute.c:2621.
      In the normal case, moved==0; but in the crashing case, "moved" is nonzero and hence the following "if" block is executed.
      
      moved = GrowEvaluationStack(iPtr->execEnvPtr, length, 1)
      - (Tcl_Obj **) bottomPtr;
      
      if (moved) {
          /*
           * Change the global data to point to the new stack.
           */
      
          bottomPtr = (BottomData *) (((Tcl_Obj **)bottomPtr) + moved);
          initCatchTop += moved;
          catchTop += moved;
          initTosPtr += moved;
          tosPtr += moved;
          esPtr = iPtr->execEnvPtr->execStackPtr;
      }
      
      I'm sure Miguel will fix that instantly ;-)
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  6. Ticket change [7811cfa6bd] (rid 89885) by andygoth on 2008-12-12 23:47:31:

    1. icomment:
      Alexandre, thank you very much for all the research you've been doing.  Twin GDB?  I will have to keep that technique in mind!
      
      
    2. login: "andygoth"
    3. mimetype: "text/plain"
    4. username: "andygoth"
  7. Ticket change [04d20401f8] (rid 88940) by msofer on 2008-12-13 00:56:04:

    1. icomment:
      Thanks for the analysis! I don't know about "instantly" (give me the weekend), but this gives me an extremely clear idea of exactly where I fscked up
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  8. Ticket change [b712e79c3d] (rid 125523) by dgp on 2008-12-19 04:43:41:

    1. icomment:
      Appears that tests basic-48.4.0
      and nre-8.1 are the only ones
      in the test suite that covers the
      stanza of code AF has identified.
      In both tests, the very long command
      created by {*} expansion comes last
      in the bytecode compiled script.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  9. Ticket change [4cf83c49e1] (rid 126986) by dgp on 2008-12-19 04:54:48:

    1. icomment:
      
      Same script is fine in Tcl 8.5.6b1,
      so I believe the flaw is in the new
      NRE code, and not the GES machinery.
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  10. Ticket change [26d0542ad4] (rid 88415) by dgp on 2008-12-19 05:15:54:

    1. icomment:
      
      Adding the line:
      
        bcFramePtr += moved;
      
      to that stanza to follow the
      pattern of the other pointers
      is enough to stop the assertion
      failure.
      
      But then we just move on to
      a segfault:
      
      2801                bcFramePtr->data.tebc.pc = (char *) pc;
      (gdb) print *bcFramePtr
      Cannot access memory at address 0x971fd80
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  11. Ticket change [dcef06ee7c] (rid 114570) by dgp on 2008-12-19 06:00:46:

    1. icomment:
      
      Ok, so making changes that make
      the assertion pass leads to a
      segfault.
      
      New theory: the assertion is
      simply mistaken.  It asserts
      something that is often, but
      not always true.  Disable it.
      
      That removes the reported trouble.
      Committing as the solution
      for 8.6b1.
      
      Leaving the report open for
      the real NRE expert to review
      when he returns to full activity.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. priority changed to: "5 Medium"
    5. username: "dgp"
  12. Ticket change [217a40599e] (rid 130589) by msofer on 2009-03-21 13:58:09:

    1. icomment:
      * generic/tclExecute.c: proper fix for [Bug 2415422]. Reenabled 
      * tests/nre.test:       the failing assertion that was disabled on 
      2008-12-18: the assertion is correct, the fault was in the
      management of expansions. 
      
      The memory move was being badly mismanaged (my bad), it worked by sheer chance. Fixed.
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  13. Ticket change [e5877ea71e] (rid 104135) by msofer on 2009-03-21 13:58:10:

    1. closedate changed to: "2009-03-21T06:58:10"
    2. closer changed to: "msofer"
    3. icomment:
      
      
      allow_comments - 1
      
      
      
    4. login: "msofer"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. username: "msofer"