|
2015-07-29
| ||
| 14:56 | [3e7eca8c8c] Prevent overflow in size values passed to allocators. check-in: 6b18af935a user: dgp tags: trunk | |
| 14:55 | • Closed ticket [3e7eca8c8c]: Large expression parse error/segfault plus 4 o... artifact: f1d89264af user: dgp | |
| 14:54 | [3e7eca8c8c] Prevent overflow in size values passed to allocators. check-in: ee467fed92 user: dgp tags: core-8-5-branch | |
| 14:31 | • Ticket [3e7eca8c8c] Large expression parse error/segfault status still Ope... artifact: b50c30fddb user: dgp | |
| 12:52 | • Ticket [3e7eca8c8c]: 3 changes artifact: 0a145e1e2b user: dgp | |
| 12:47 | • Open ticket [3e7eca8c8c]. artifact: aed38859a1 user: dgp | |
| 11:10 | • Closed ticket [3e7eca8c8c]. artifact: a8050f8ba8 user: sebres | |
| 10:48 | • Pending ticket [3e7eca8c8c]. artifact: 7c8f2d63b5 user: sebres | |
| 10:06 | • Closed ticket [3e7eca8c8c]. artifact: c1d57b192a user: dgp | |
| 10:03 | [3e7eca8c8c] Prevent overflow in the size value passed to ckrealloc(). check-in: 09d77bdb2a user: dgp tags: trunk | |
| 03:06 | [3e7eca8c8c] Prevent overflow in the size value passed to ckrealloc(). check-in: 675e880454 user: dgp tags: core-8-5-branch | |
|
2015-07-28
| ||
| 21:14 | • Ticket [3e7eca8c8c] Large expression parse error/segfault status still Ope... artifact: f8d05c0283 user: dgp | |
| 19:57 | • New ticket [3e7eca8c8c]. artifact: 386e20e515 user: dgp | |
Large [expr]ession parse error/segfault
Closed / Fixed3e7eca8c8c70ce1b50d4feeea12bef11e26c1227Created 11 years agoUpdated 11 years ago
Descriptionplain2015-07-28 19:57:50
From RickyB98 on the chat:
% info patch
8.6.4
% set go 1; set string 3; while {$go} {incr iter; append string +4/double([incr x 2]*($x+1)*($x+2))-4/double([incr x 2]*($x+1)*($x+2)); if {$iter > 10000000} {set go 0}}; concat
% string length $string
883333447
% time {expr $string}
unbalanced close paren
in expression "...e(26843546*(26843546+1)*(26843546+2))-4/doubl..."
% exit
Original report was a segfault, and that indeed happens with Tcl 8.5.9.
On trunk and core-8-5-branch tip we get the (false) parsing error
message instead.
Initial guess is that we're overflowing something or other.
Referenced by4
6b18af935a[3e7eca8c8c] Prevent overflow in size values passed to allocators. check-in2015-07-29 14:56:20ee467fed92[3e7eca8c8c] Prevent overflow in size values passed to allocators. check-in2015-07-29 14:54:1309d77bdb2a[3e7eca8c8c] Prevent overflow in the size value passed to ckrealloc(). check-in2015-07-29 10:03:46675e880454[3e7eca8c8c] Prevent overflow in the size value passed to ckrealloc(). check-in2015-07-29 03:06:30
dgpplain2015-07-28 21:14:13
Initial debugging shows the bad parse taking place when the size of the nodes array is 268435456. Since the OpNode struct seems to be of size 32 bytes, that does seem to indicate we're getting too big for our ckalloc'ed britches.
dgpplain2015-07-29 10:06:17
Overflow of allocation size repaired. Believe that's all of the problem, but hard to say since once parsing is repaired, that expression doesn't compute in less than hours. Quite possible days or even much much more.
sebresplain2015-07-29 10:48:04
Are you sure, really?
If I look at this code - I see an endless cycle if size > UINT_MAX/sizeof(OpNode) ...
```
OpNode *newPtr = NULL;
do {
if (size <= UINT_MAX/sizeof(OpNode)) {
newPtr = (OpNode *) attemptckrealloc((char *) nodes,
(unsigned int) size * sizeof(OpNode));
}
} while ((newPtr == NULL)
```
Regards, sebres
sebresplain2015-07-29 11:10:40
Sorry, was my mistake, I have missed a line bottom, that belong this cycle also: && ((size -= (size - nodesUsed) / 2) > nodesUsed)); Thus is alright and ticket closed.
dgpplain2015-07-29 12:47:56
It appears that my "days to calculate" observation came
from doing the testing on a system starved for memory.
Now on a better resourced system, I get:
% set iter 0; set string 3; set x 0
0
% while {[incr iter] <= 7000000} {
append string +4/double([incr x 2]*($x+1)*($x+2))-4/double([incr x 2]*($x+1)*($x+2))
}; concat
% time {expr $string}
make: *** [shell] Segmentation fault
7M terms is enough to prompt another segfault. Maybe compiling.
Maybe execution.
dgpplain2015-07-29 12:52:34
sorry, no. Made an error and tested on an unpatched sandbox. Without the patch, the error is still there!
dgpplain2015-07-29 14:31:02
The next actual failure I see is a panic unable to allocate enough memory for an expansion of the literal table. Even on a system with more memory, the literal table limits appear to be reached with this example.
dgp Closed ticket [3e7eca8c8c].
[History diff]2015-07-29 14:55:55
Log in (anonymous is fine) to add a comment.