Skip to content
Tcl Source Code History Of Ticket 2017857
Login

History Of Ticket 2017857

Artifacts Associated With Ticket 2017857

  1. Ticket change [950f8ee69d] (rid 106097) by tallniel on 2008-07-14 10:33:23:

    1. assignee initialized to: "msofer"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      I'm seeing a crash testing NRE tailcall on Windows XP, using a tclsh86sg built from current CVS head (VS.NET 2003, static, symbols). Currently trying to track down the problem, possibly a funny interaction between [uplevel] and [tailcall]. I'll try and create a minimal example. In the meantime, the code that causes the crash is http://wiki.tcl.tk/16695. Copy that code to an editor, and then add the following interp alias at the top:
      
       interp alias {} tailcall {} ::tcl::unsupported::tailcall
      
      Then change the term::fold procedure to use [tailcall]:
      
       proc term::fold {f z t} {
          match $t {
      {Lambda var body}   -> { tailcall $f lam $z $var $body }
      {Apply a b}    -> { tailcall $f app $z [fold $f $z $a] [fold $f $z $b] }
      {Var name}    -> { tailcall $f var $z $name }
      {IntLit i}    -> { tailcall $f int $z $i }
      {Add a b}    -> { tailcall $f add $z [fold $f $z $a] [fold $f $z $b] }
      {Sub a b}    -> { tailcall $f sub $z [fold $f $z $a] [fold $f $z $b] }
      {Mul a b}    -> { tailcall $f mul $z [fold $f $z $a] [fold $f $z $b] }
      {Div a b}    -> { tailcall $f div $z [fold $f $z $a] [fold $f $z $b] }
          }
       }
      
      This is an interesting case, as [match] uses both [uplevel] and [dict with], so plenty of tricksiness going on here. Possibly might not be ok to call [tailcall] here, but should produce an error rather than a crash. Crash seems to be an invalid pointer deref (cannot access location 0x00000014). Stack dump:
      
      >tclsh86sg.exe!TclExecuteByteCode(Tcl_Interp * interp=0x00afa8b8, ByteCode * codePtr=0x00b86ae0)  Line 2741 + 0xcC
       tclsh86sg.exe!NRPostProcess(Tcl_Interp * interp=0x00afa8b8, int result=0, int objc=0, Tcl_Obj * const * objv=0x00000000)  Line 7419 + 0x10C
       tclsh86sg.exe!TclEvalObjEx(Tcl_Interp * interp=0x00afa8b8, Tcl_Obj * objPtr=0x00b5e5e8, int flags=0, const CmdFrame * invoker=0x00afb314, int word=1)  Line 5327 + 0x11C
       tclsh86sg.exe!Tcl_CatchObjCmd(void * dummy=0x00000000, Tcl_Interp * interp=0x00afa8b8, int objc=3, Tcl_Obj * const * objv=0x00afb33c)  Line 253 + 0x1eC
       tclsh86sg.exe!Tcl_EvalObjv(Tcl_Interp * interp=0x00afa8b8, int objc=3, Tcl_Obj * const * objv=0x00afb33c, int flags=2097152)  Line 4079 + 0x15C
       tclsh86sg.exe!TclExecuteByteCode(Tcl_Interp * interp=0x00afa8b8, ByteCode * codePtr=0x00b67840)  Line 2696 + 0x1cC
       tclsh86sg.exe!NRPostProcess(Tcl_Interp * interp=0x00afa8b8, int result=0, int objc=0, Tcl_Obj * const * objv=0x00000000)  Line 7419 + 0x10C
       tclsh86sg.exe!TclEvalObjEx(Tcl_Interp * interp=0x00afa8b8, Tcl_Obj * objPtr=0x00b862d0, int flags=0, const CmdFrame * invoker=0x00afb1c0, int word=2)  Line 5327 + 0x11C
       tclsh86sg.exe!Tcl_WhileObjCmd(void * dummy=0x00000000, Tcl_Interp * interp=0x00afa8b8, int objc=3, Tcl_Obj * const * objv=0x00afb1f0)  Line 4029 + 0x1eC
       tclsh86sg.exe!Tcl_EvalObjv(Tcl_Interp * interp=0x00afa8b8, int objc=3, Tcl_Obj * const * objv=0x00afb1f0, int flags=2097152)  Line 4079 + 0x15C
       tclsh86sg.exe!TclEvalEx(Tcl_Interp * interp=0x00afa8b8, const char * script=0x00b81ec8, int numBytes=6872, int flags=0, int line=219)  Line 5044 + 0x16C
       tclsh86sg.exe!Tcl_EvalEx(Tcl_Interp * interp=0x00afa8b8, const char * script=0x00b81ec8, int numBytes=6872, int flags=0)  Line 4751 + 0x17C
       tclsh86sg.exe!Tcl_FSEvalFileEx(Tcl_Interp * interp=0x00afa8b8, Tcl_Obj * pathPtr=0x00b69f28, const char * encodingName=0x00000000)  Line 1776 + 0x13C
       tclsh86sg.exe!Tcl_Main(int argc=-1, char * * argv=0x00af38e8, int (Tcl_Interp *)* appInitProc=0x00401070)  Line 443 + 0x11C
       tclsh86sg.exe!main(int argc=2, char * * argv=0x00af38e0)  Line 102 + 0x12C
       tclsh86sg.exe!mainCRTStartup()  Line 259 + 0x19C
       kernel32.dll!7c816fd7() 
      
      Offending line in tclExecute.c:
          iPtr->cmdFramePtr = iPtr->cmdFramePtr->nextPtr;
      
      I can't dig into that structure to see what those fields are set to as iPtr is just a #define, and the interp pointer shows nothing interesting. Looks like iPtr->cmdFramePtr is invalid at this point.
      
    4. foundin initialized to: "obsolete: 8.6a1"
    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: "tallniel"
    10. subsystem initialized to: "45. Parsing and Eval"
    11. title initialized to: "NRE crash calling tailcall from uplevel context"
    12. type initialized to: "Bug"
  2. Ticket change [7a01df8a95] (rid 90230) by dkf on 2008-07-14 17:45:14:

    1. icomment:
      Logged In: YES 
      user_id=79902
      Originator: NO
      
      Fact points to help chasing this down: [dict with] is not bytecoded (I didn't have the time to figure it out) and has a substantial amount of code to execute after the body. Some of said code *must* execute, even in error cases; disrupting that will cause trouble, memory leaks, nasal demons, the end of the world, cats and dogs living together, etc.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  3. Ticket change [2a32d5c646] (rid 118513) by tallniel on 2008-07-14 17:50:56:

    1. icomment:
      Logged In: YES 
      user_id=102050
      Originator: YES
      
      Definitely an interaction with [dict with] rather than [uplevel]. Minimal script to reproduce bug:
      
       package require Tcl 8.6a1
       proc test env {
           dict with env { tcl::unsupported::tailcall test {} }
       }
       test ""
      
      (Note: if/when fixed this proc will result in an infinite loop).
      
      
    2. login: "tallniel"
    3. mimetype: "text/plain"
    4. priority changed to: "9 Immediate"
    5. username: "tallniel"
  4. Ticket change [828191137e] (rid 117246) by tallniel on 2008-07-14 17:51:16:

    1. title changed to: "NRE crash calling tailcall from [dict with]"
  5. Ticket change [050d47a5c7] (rid 88985) by dkf on 2008-07-14 19:17:59:

    1. icomment:
      Logged In: YES 
      user_id=79902
      Originator: NO
      
      sounds like that means that [dict with] needs NRE-ing
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  6. Ticket change [aaea4b348d] (rid 101004) by dkf on 2008-07-18 04:57:39:

    1. icomment:
      Logged In: YES 
      user_id=79902
      Originator: NO
      
      done, but leaving open as I ran across a problem
      
      The problem was that while TclNREvalObjEx works just fine if the thing being evaluated is a general script, it crashes if it is the same command twice (see test dict-21.10 for an example). I've worked around it with TclNR_EvalObj but that breaks TIP#280 promises, so this is a short-term solution only.
      
      Two places to fix in tclDictObj.c, one at end of DictUpdateCmd, one at end of DictWithCmd.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  7. Ticket change [4114d08d3d] (rid 116116) by andreas_kupries on 2008-07-18 05:06:19:

    1. icomment:
      Logged In: YES 
      user_id=75003
      Originator: NO
      
      Oh, let me note something here. The cmdFrame structure for the info frame stack is kept on the C-stack, see for example TEBC, bcFrame. Then there are eoFrame and eeFrame (EvalObj, and EvalEx). The bcFrame being mismanaged because of the trampolining, that might be the cause of the nested dict crash.
      
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  8. Ticket change [602e1f56d3] (rid 115949) by msofer on 2008-07-18 11:32:54:

    1. closedate changed to: "2008-07-18T04:32:54"
    2. closer changed to: "msofer"
    3. icomment:
      Logged In: YES 
      user_id=148712
      Originator: NO
      
      Crash fixed (refcounting bug); cmdFrame management was ok (all on the Tcl stack).
      
      
    4. login: "msofer"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. username: "msofer"