Skip to content
Tcl Source Code History Of Ticket 8ecaee5d83a8d869
Login

History Of Ticket 8ecaee5d83a8d869

Artifacts Associated With Ticket 8ecaee5d83a8d869

  1. Ticket change [ee4c2e82bc] (rid 162571) by dgp on 2018-04-23 03:27:38:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      In a --enable-symbols=mem build of Tcl, both tests var-23.10 and var-23.11 segfault.
      
      This is because the unset operations in the loop bodies cause searchPtr to be freed,
      yet ArrayForLoopCallback() operates on the fields of searchPtr right away with nothing
      to check the memory is still allocated.
      
      Array searches are still not yet founded on a proper design.
      
    5. foundin initialized to: "8.7"
    6. is_private initialized to: "0"
    7. login: "dgp"
    8. priority initialized to: "5 Medium"
    9. resolution initialized to: "None"
    10. severity initialized to: "Critical"
    11. status initialized to: "Open"
    12. submitter initialized to: "dgp"
    13. subsystem initialized to: "07. Variables"
    14. title initialized to: "[array for] memory corruption"
    15. type initialized to: "Bug"
  2. Ticket change [8cf68b864c] (rid 162574) by bll on 2018-04-23 10:51:35:

    1. icomment:
      The varPtr assignment needs to be moved below the result check.
      
      Index: generic/tclVar.c
      ==================================================================
      --- generic/tclVar.c
      +++ generic/tclVar.c
      @@ -3128,12 +3128,10 @@
           /*
            * Process the result from the previous execution of the script body.
            */
       
           done = TCL_ERROR;
      -    varPtr = TclObjLookupVarEx(interp, searchPtr->arrayNameObj, NULL, /*flags*/ 0,
      -           /*msg*/ 0, /*createPart1*/ 0, /*createPart2*/ 0, &arrayPtr);
       
           if (result == TCL_CONTINUE) {
              result = TCL_OK;
           } else if (result != TCL_OK) {
              if (result == TCL_BREAK) {
      @@ -3144,10 +3142,13 @@
                          "\n    (\"array for\" body line %d)",
                          Tcl_GetErrorLine(interp)));
              }
              goto arrayfordone;
           }
      +
      +    varPtr = TclObjLookupVarEx(interp, searchPtr->arrayNameObj, NULL, /*flags*/ 0,
      +           /*msg*/ 0, /*createPart1*/ 0, /*createPart2*/ 0, &arrayPtr);
       
           /*
            * Get the next mapping from the array.
            */
      
    2. login: "bll"
    3. mimetype: "text/plain"
  3. Ticket change [dbbb18fcbc] (rid 162575) by dgp on 2018-04-23 11:39:44:

    1. icomment:
      
      Thanks. That does look like an improvement, but it doesn't solve the problem.
      
      Program received signal SIGSEGV, Segmentation fault.
      0x0000000000589a7b in TclObjLookupVarEx (interp=0x83a678, 
          part1Ptr=0x6161616161616161, part2Ptr=0x0, flags=0, msg=0x0, 
          createPart1=0, createPart2=0, arrayPtrPtr=0x7fffffffd020)
          at /home/dgp/fossil/tcl8.7/generic/tclVar.c:551
      551         const Tcl_ObjType *typePtr = part1Ptr->typePtr;
      Missing separate debuginfos, use: debuginfo-install glibc-2.17-196.el7_4.2.x86_64 zlib-1.2.7-17.el7.x86_64
      (gdb) bt
      #0  0x0000000000589a7b in TclObjLookupVarEx (interp=0x83a678, 
          part1Ptr=0x6161616161616161, part2Ptr=0x0, flags=0, msg=0x0, 
          createPart1=0, createPart2=0, arrayPtrPtr=0x7fffffffd020)
          at /home/dgp/fossil/tcl8.7/generic/tclVar.c:551
      #1  0x000000000058d0ef in ArrayForLoopCallback (data=0xe1ade0, 
          interp=0x83a678, result=0) at /home/dgp/fossil/tcl8.7/generic/tclVar.c:3147
      #2  0x0000000000430d24 in TclNRRunCallbacks (interp=0x83a678, result=0, 
          rootPtr=0x0) at /home/dgp/fossil/tcl8.7/generic/tclBasic.c:4494
      
      When the problem arises, ArrayForLoopCallback() is entered with
      result == TCL_OK. It is this pass through the routine that is 
      supposed to notice the array change and report the error.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  4. Ticket change [505c59f544] (rid 162576) by bll on 2018-04-23 12:27:58:

    1. icomment:
      Ugh.  I suppose an additional hash entry must be made in the
      varSearches hash table in order to save the array name.
      
    2. login: "bll"
    3. mimetype: "text/plain"
  5. Ticket change [2c0cd4d338] (rid 162581) by bll on 2018-04-23 13:01:55:

    1. icomment:
      Ok, having the arrayNameObj in the ArraySearch structure would never work.
      Fortunately, there was still a slot available in the NRE callback to pass
      another variable.
      
      I also moved the duplicated code to populate the search structure into a new routine.
      
      http://core.tcl.tk/tcl/info/70852914044fa64a
      
    2. login: "bll"
    3. mimetype: "text/plain"
  6. Ticket change [b8ad1cd7c3] (rid 162588) by dgp on 2018-04-23 13:54:10:

    1. closedate changed to: "2458232.07928297"
    2. closer changed to: "dgp"
    3. icomment:
      
      That appears to have solve that issue.  Thanks for the work repairing the
      rotten foundations! (Not your fault that they were rotten to begin with).
      
      Will keep hammering on [array for] as I can.
      
    4. login: "dgp"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"