Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2009-06-11
04:40 • Closed ticket [2801413fff]: format %llx overflow plus 7 other changes artifact: ef003855cd user: dgp
04:23 • Ticket [2801413fff]: 4 changes artifact: 65348684b8 user: dgp
04:22 • Ticket [2801413fff]: 4 changes artifact: 672424a5b9 user: dgp
04:22 • Add attachment 2801413.patch to ticket [2801413fff] artifact: cedb49deff user: dgp
04:21 • Ticket [2801413fff] format %llx overflow status still Open with 4 other ch... artifact: 94a40b7dc8 user: dgp
2009-06-06
05:04 • Ticket [2801413fff]: 4 changes artifact: f99a08cfea user: dgp
05:04 • Ticket [2801413fff]: 4 changes artifact: 024b60baf8 user: dgp
2009-06-04
22:06 • New ticket [2801413fff]. artifact: 276b2b4572 user: dgp

[format %llx] overflow

Closed / Fixed2801413fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 17 years ago
Descriptionplain2009-06-04 22:06:02
% set x [expr {1<<(2**29)}]; concat
% set x [expr {$x<<(2**29)}]; concat
% set x [expr {$x<<(2**29)}]; concat
% set x [expr {$x<<(2**29)}]; concat
% incr x -1; concat
% set s [format %#llx $x]; concat
Tcl_SetObjLength: negative length requested: -536870912 (integer overflow?)

Computing the value of numDigits overflows
the int range.
dgpplain2009-06-06 05:04:14
After applying attached patch:

% set max [expr {(1<<(2**31-3)<<(2**31-3)<<(2**31-3)<<(2**31-3))-1}]; concat
% set s [format %#llx $max]; concat
% string length $s
2147483647
% incr max; concat
% set s [format %#llx $max]; concat
max size for a Tcl value (2147483647 bytes) exceeded

This demos ability of [format] to create a numeric
string up to Tcl's limits.

A panic when those limits are exceeded is a bit
jarring, but that's a separate bug/misfeature.
dgpplain2009-06-06 05:04:52
File Added - 329932: 2801413.patch
dgpplain2009-06-11 04:21:37
File Deleted - 329932:
dgpplain2009-06-11 04:22:37
File Added - 330526: 2801413.patch
dgpplain2009-06-11 04:23:23
Updated patch also converts all
[format] panics due to string length
overflow into simple Tcl errors.
dgpplain2009-06-11 04:40:21
allow_comments - 1

patch committed for 8.5.8 and 8.6b2.
Log in (anonymous is fine) to add a comment.

Attachments: