Skip to content
Tcl Source Code History Of Ticket 2835313
Login

History Of Ticket 2835313

Artifacts Associated With Ticket 2835313

  1. Ticket change [685194c379] (rid 103046) by dgp on 2009-08-11 03:09:56:

    1. assignee initialized to: "msofer"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      
      % proc foo args {puts $args}
      % while 1 {foo 1 2 3 [continue] 5 6}
      Segmentation fault
      
      Also crashes 8.4.19, 8.3.5, 8.2.3, 8.1.0
      
      Hangs 8.0.5
      
      Something deep in the design of
      ExceptionRanges etc. just doesn't
      handle this right.
      
      
    4. foundin initialized to: "obsolete: 8.5.7"
    5. is_private initialized to: "0"
    6. priority initialized to: "8"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "dgp"
    10. subsystem initialized to: "47. Bytecode Compiler"
    11. title initialized to: "crash in exception handling"
    12. type initialized to: "Bug"
  2. Ticket change [740ed536be] (rid 105136) by dgp on 2009-08-11 10:38:45:

    1. icomment:
      
      Joe Mistachkin kindly reminds me that
      hanging it proper functioning for this example.
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  3. Ticket change [151dc16adc] (rid 124514) by dgp on 2009-08-11 11:27:50:

    1. icomment:
      
      From a debug build:
      
      % while 1 {foo [continue]}
      
      Bad stack top 2 at pc 2 in TclExecuteByteCode (min 0, max 1)
       executing continue
      TclExecuteByteCode execution failure: bad stack top
      
      Program received signal SIGABRT, Aborted.
      0x40000402 in __kernel_vsyscall ()
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  4. Ticket change [2f31c69002] (rid 93023) by msofer on 2009-08-22 04:42:06:

    1. icomment:
      This cannot be fixed easily without deep changes in the exception range mechanism, or possibly some costly extra functionality in INST_START_CMD. 
      
      The problem is that the exec stack depth is not recorded on entering an exception range: neither at compile time, which would be iffy, nor at run time (catch does it with INST_BEGIN_CATCH). 
      
      Given this, there is no way to restore the stack when jumping to one of the special targets (continue or break). The whole mechanism just ASSUMES that the stack is at its proper depth when a jump to one of the targets occurs.
      
      That is: a solution to this problem is possible, but it will definitely break in a difficult-to-fix way [tbcloading] old precompiled programs. Some day we might decide to do that.
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  5. Ticket change [b58dcf3e91] (rid 125265) by msofer on 2010-05-17 19:49:31:

    1. priority changed to: "7 High"
  6. Ticket change [a7272c3573] (rid 98737) by dkf on 2010-09-01 17:56:20:

    1. icomment:
      This issue was encountered yesterday on the Tcler's chat when kbk was trying to explain to dogeen what an exception range is.
      
      One possible fix would be to create an extra instruction which clears the stack down to a given mark. Old code wouldn't use it, but that's also probably not having a problem anyway.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  7. Ticket change [1339fafa0c] (rid 124176) by dkf on 2013-06-05 15:15:17:

    1. assignee changed to: "dkf"
    2. closedate changed to: "2013-06-05T08:15:17"
    3. closer changed to: "dkf"
    4. icomment:
      
      
      allow_comments - 1
      
      Fixed on trunk. Will not backport as the changes were quite extensive internally (and dealing with jumping past {*}expansion required a new opcode).
      
      
    5. login: "dkf"
    6. mimetype: "text/plain"
    7. resolution changed to: "Fixed"
    8. status changed to: "Closed"
    9. username: "dkf"
  8. Ticket change [54fbc9b468] (rid 134787) by dkf on 2013-10-20 18:41:35:

    1. closedate changed to: "2456586.27888628"
    2. comment changed to:
      % proc foo args {puts $args}
      % while 1 {foo 1 2 3 [continue] 5 6}
      Segmentation fault
      
      Also crashes 8.4.19, 8.3.5, 8.2.3, 8.1.0
      
      Hangs 8.0.5
      
      Something deep in the design of
      ExceptionRanges etc. just doesn't
      handle this right.
      
    3. icomment:
      Dealt with the <i>other</i> ways in which exceptions could be generated. Evilness abounded!
      <h2>Analysis</h2>
      <span style="float:left;font-size:700%;color:red;border-width:medium"><b>!</b></span>
      This was in fact one of the most serious bugs in Tcl's implementation that existed; it allowed a whole range of attacks against Tcl deployments that were impossible to guard against without totally crippling the language. I'm only willing to admit just how serious this was now that I've got code in place that makes the problem impossible to exploit, though it should be noted that a backport to 8.5 is definitely impossible.
      <p>
      <b>Execution of untrusted code in a critical environment will be <i>strongly recommended against</i> until Tcl 8.6.2</b>. This applies even in a safe interpreter. It is <i>not</i> believed possible to exploit this in any way other than forcing a process to hang or crash, as it is not possible for the attacker to control the locations of any values in Tcl or to force them to be placed at any known location.
      <h2>Mitigation Strategies</h2>
      A mitigation is to use a build of Tcl that has been configured with <tt>--enable-symbols=compile</tt>, as that will trap Tcl execution stack imbalances and convert them into definite crashes (i.e., a call to <tt>Tcl_Panic()</tt>); the disadvantage of that mechanism is that there is a substantial performance penalty. Code must also be written to cope with the process crashing (if desired), perhaps via a watchdog parent process; at the point where the problem is detected, insufficient information remains in the process to determine what the cause was.
      
    4. login: "dkf"
    5. mimetype: "text/html"
    6. priority changed to: "9 Immediate"
    7. severity changed to: "Critical"
    8. username: "dkf"
  9. Ticket change [1d2c927c99] (rid 134798) by dgp on 2013-10-21 14:51:13:

    1. closer changed to: "nobody"
    2. icomment:
      Troubles on the trunk (--enable-symbols=all testing):
      
      ---- assemble-16.5 start
      Test file error: bad stack adjustment when compiling tcl::unsupported::assemble (was -1 instead of 1)
      
      
      ---- for-7.14 start
      Test file error:
      Bad stack top 13 at pc 182 in TclNRExecuteByteCode (min 0, max 12)
       executing for {set x 0} {[incr x]<50} {} {
                      puts [puts {*}$l {*}[puts a b c {*}$l {*}[apply {{} {
                          re...
      TclNRExecuteByteCode execution failure: bad stack top
      
    3. login: "dgp"
    4. mimetype: "text/plain"
    5. status changed to: "Open"
  10. Ticket change [b3c564844e] (rid 134799) by dgp on 2013-10-21 16:24:09:

    1. icomment:
      Other panicking tests:
      
      assemble-16.6
      assemble-30.[123]
      
      for-7.22
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  11. Ticket change [ca781e66d1] (rid 134810) by dkf on 2013-10-21 18:28:45:

    1. icomment:
      <tt>for-7.*</tt> are the tests I've committed specifically to detect issues relating to this bug; they try very hard to break things.
      
    2. login: "dkf"
    3. mimetype: "text/html"
    4. username: "dkf"
  12. Ticket change [a5257e9063] (rid 134860) by dkf on 2013-10-22 14:31:21:

    1. icomment:
      Problems in <tt>for.test</tt> were due to a total think-o. Still investigating <tt>assemble.test</tt>…
      
    2. login: "dkf"
    3. mimetype: "text/html"
    4. username: "dkf"
  13. Ticket change [f78e189b26] (rid 134879) by dkf on 2013-10-22 18:28:45:

    1. assignee changed to: "kbk"
    2. icomment:
      Only simple fix for <tt>assemble.test</tt> problems is to roll back the changes in <tt>tclAssemble.c</tt>.
      <blockquote>
      <hr>
      The deep problem is that <i>invokeStk</i> is issued within a basic block, yet can throw exceptions. In particular, it can throw <i>TCL_BREAK</i> and <i>TCL_CONTINUE</i> with a trapping loop context outside the assembled code. Attempting to do the stack rebalance with the same machinery as used in the rest of the compiler won't work, as the information required to do so (the current and target stack- and expansion-depths, and so the size of correction to apply) is not present in the same format due to the basic block management mechanism. I don't know how to do that. (It all becomes much more pressing/complex once/if loop exception ranges become issuable in the assembler.)
      <p>
      Because of these deeper problems, I'm now assigning this to the assembler maintainer for consideration and fix/reject-fixing. (Right now, the assembler is the only way to generate the sort of trouble described in this bug report.)
      </blockquote>
      
    3. login: "dkf"
    4. mimetype: "text/html"
    5. priority changed to: "7 High"
    6. severity changed to: "Severe"
    7. username: "dkf"
  14. Ticket change [f5717d5591] (rid 140210) by dgp on 2014-10-09 15:12:33:

    1. assignee changed to: "dkf"
    2. icomment: "Anything left to do here?"
    3. login: "dgp"
    4. mimetype: "text/plain"
  15. Ticket change [16791ea95b] (rid 140298) by dkf on 2014-10-11 16:03:42:

    1. closedate changed to: "2456942.16923911"
    2. closer changed to: "dkf"
    3. icomment:
      No. The issues that remain with the assembler are deep and nasty, but need addressing in the assembler through different mechanisms. Since there's no explicit <tt>break</tt>, <tt>continue</tt> or <tt>return...</tt> instructions, the problems are as averted as I can manage. (The real fix would involve using something like <tt>beginCatch</tt>/<tt>endCatch</tt> for all loops. Which is heavyweight.)
      
    4. login: "dkf"
    5. mimetype: "text/html"
    6. status changed to: "Closed"
    7. username: "dkf"