Artifacts Associated With Ticket 5d989f9ba3
Ticket change [e19c8a4746] (rid 178627) by mauricek on 2020-01-17 10:45:35:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- 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. - foundin initialized to: "8.6"
- is_private initialized to: "0"
- login: "mauricek"
- priority initialized to: "5 Medium"
- private_contact initialized to: "f4133a2c7edf126fe2f5e0da683dc0ce83c9e85d"
- resolution initialized to: "None"
- severity initialized to: "Severe"
- status initialized to: "Open"
- submitter initialized to: "mauricek"
- subsystem initialized to: "14. List Object"
- title initialized to: "Seg fault in lsort for large list length"
- type initialized to: "Bug"
Ticket change [d3fcd2a77d] (rid 178628) by sebres on 2020-01-17 13:09:38:
- 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.
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [2ed0526ac6] (rid 178657) by sebres on 2020-01-17 18:47:38:
- closedate changed to: "2458866.28308704"
- closer changed to: "sebres"
- 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.
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Closed"