|
2020-01-29
| ||
| 16:50 | better test covering [5d989f9ba3] - limiting AS considers normal memory usage of process; prepared f... check-in: 3473d9551a user: sebres tags: core-8-5-branch | |
|
2020-01-17
| ||
| 18:47 | • Closed ticket [5d989f9ba3]: Seg fault in lsort for large list length plus 6 ... artifact: 2ed0526ac6 user: sebres | |
| 17:08 | merge 8.5 (closes [5d989f9ba3]: avoid segfault by OOM if too many items to sort) check-in: 0c2487fce9 user: sebres tags: core-8-6-branch | |
| 16:12 | closes [5d989f9ba3]: avoid segfault by OOM if too many items to sort (would throw an error instead, ... check-in: cbee73ad7c user: sebres tags: core-8-5-branch | |
| 13:09 | • Ticket [5d989f9ba3] Seg fault in lsort for large list length status still Op... artifact: d3fcd2a77d user: sebres | |
| 10:45 | • New ticket [5d989f9ba3]. artifact: e19c8a4746 user: mauricek | |
Seg fault in lsort for large list length
Closed / Fixed5d989f9ba34bb5c3457bfee1737daeff565efa13Created 7 years agoUpdated 7 years ago
Descriptionplain2020-01-17 10:45:35
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.
Referenced by3
3473d9551abetter test covering [5d989f9ba3] - limiting AS considers normal memory usage of process; prepared for new common test-facility (test-with-limit) for resticted execution check-in2020-01-29 16:50:560c2487fce9merge 8.5 (closes [5d989f9ba3]: avoid segfault by OOM if too many items to sort) check-in2020-01-17 17:08:18cbee73ad7ccloses [5d989f9ba3]: avoid segfault by OOM if too many items to sort (would throw an error instead, and use system alloc for long elementArray due to size_t); added test cases covering that (in child process with limited address space, if "prlimit" available) check-in2020-01-17 16:12:06
sebreswiki2020-01-17 13:09:38
I've fixed that for >= 8.5.
I'll push the fix soon, just thinking about tests, but...
Although the tests ware simple:
# 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
but are to slow and expecting constrants or some condition to bypass possible OOM situation if testing in env with few memory.
sebreswiki2020-01-17 18:47:38
Fixed for 8.5, merged in [0c2487fce9] for 8.6 and above.
And (more or less "good") test added for coverage.
Lets close it.
Log in (anonymous is fine) to add a comment.