Skip to content
Tcl Source Code History Of Ticket 5d989f9ba34bb5c3
Login

History Of Ticket 5d989f9ba34bb5c3

Artifacts Associated With Ticket 5d989f9ba34bb5c3

  1. Ticket change [e19c8a4746] (rid 178627) by mauricek on 2020-01-17 10:45:35:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      Builtin lsort command seg faults for a list with length > 89,478,485 in Tcl8.6.6.
      
      The problem occurs dues to int overflow in the allocation of elementArray on line
      3965 of tclCmdIL.c. The size paramater to TclStackAlloc is an int:
          (int) length * sizeof(SortElement)
      which will overflow for the length quoted above. 
      
      It is also worth noting that the same problem occurs in Tcl8.5 but requires a 
      list twice as long (i.e. length > 178,956,970) since in 8.5 the allocation
      function takes unsigned int as a parameter and so needs a larger list to
      overflow.
      
      I understand the 2G object size limit that exists in TCL but this seg fault is
      unexpected as the list size needed to trigger it is much smaller than expected
      due to the increase by factor sizeof(SortElement) == 24.
      
    5. foundin initialized to: "8.6"
    6. is_private initialized to: "0"
    7. login: "mauricek"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "f4133a2c7edf126fe2f5e0da683dc0ce83c9e85d"
    10. resolution initialized to: "None"
    11. severity initialized to: "Severe"
    12. status initialized to: "Open"
    13. submitter initialized to: "mauricek"
    14. subsystem initialized to: "14. List Object"
    15. title initialized to: "Seg fault in lsort for large list length"
    16. type initialized to: "Bug"
  2. Ticket change [d3fcd2a77d] (rid 178628) by sebres on 2020-01-17 13:09:38:

    1. icomment:
      I've fixed that for >= 8.5.<br/>
      I'll push the fix soon, just thinking about tests, but...
      
      Although the tests ware simple:
      <pre style="padding-left:10pt"><code>
      # 8.6 (x64):
      $ echo 'puts [llength [set l [lrepeat 89478486 ""]]]; puts [llength [lsort $l]]' | tclsh
      89478486
      Segmentation fault
      
      # 8.5 (x32):
      $ echo 'puts [llength [set l [lrepeat 178956971 ""]]]; puts [llength [lsort $l]]' | tclsh
      178956971
      Segmentation fault
      </code></pre>
      but are to slow and expecting constrants or some condition to bypass possible OOM situation if testing in env with few memory.
      
    2. login: "sebres"
    3. mimetype: "text/x-fossil-wiki"
  3. Ticket change [2ed0526ac6] (rid 178657) by sebres on 2020-01-17 18:47:38:

    1. closedate changed to: "2458866.28308704"
    2. closer changed to: "sebres"
    3. icomment:
      Fixed for 8.5, merged in [0c2487fce9] for 8.6 and above.<br/>
      And (more or less "good") test added for coverage.<br/>
      Lets close it.
      
    4. login: "sebres"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"