Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: e19c8a4746d1648a1579e684aa161b50bca1dc86d799bcdf7f13fee8f72a0aaa
Ticket: 5d989f9ba34bb5c3457bfee1737daeff565efa13
Seg fault in lsort for large list length
User & Date: mauricek on 2020-01-17 10:45:35
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed 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 changed to: "8.6"
  6. is_private changed to: "0"
  7. login: "mauricek"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "f4133a2c7edf126fe2f5e0da683dc0ce83c9e85d"
  10. resolution changed to: "None"
  11. severity changed to: "Severe"
  12. status changed to: "Open"
  13. submitter changed to: "mauricek"
  14. subsystem changed to: "14. List Object"
  15. title changed to: "Seg fault in lsort for large list length"
  16. type changed to: "Bug"