Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2009-02-05
02:04 • Closed ticket [2561746fff]: overflow trouble in string repeat plus 8 other... artifact: 8ea635976c user: dgp
01:16 • Ticket [2561746fff]: 4 changes artifact: 9aab5ce4bc user: dgp
01:14 • Ticket [2561746fff]: 4 changes artifact: c0b701e7ae user: dgp
2009-02-04
23:20 • Ticket [2561746fff]: 4 changes artifact: dbec088a0f user: dgp
02:43 • Ticket [2561746fff]: 4 changes artifact: 8c42a171fa user: dgp
02:32 • Ticket [2561746fff]: 5 changes artifact: 1e469ccf3d user: dgp
02:20 • Ticket [2561746fff]: 4 changes artifact: 2577494257 user: dgp
2009-02-03
19:18 • New ticket [2561746fff]. artifact: e089979cac user: dgp

overflow trouble in [string repeat]

Closed / Fixed2561746fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 18 years ago
Descriptionplain2009-02-03 19:18:48
% info patch
8.5.6
% set a [string repeat a 0x80000000]; concat
% string length $a
0
dgpplain2009-02-04 02:20:41
Related:

% set a [string repeat a 0x7fffffff]; concat
string size overflow, out of memory allocating -2147483648 bytes

Here it's just the formatting of the
error message that is the problem.
dgpplain2009-02-04 02:32:12
On another system with more memory:

% set a [string repeat a 0x7fffffff]; concat
Segmentation fault
dgpplain2009-02-04 02:43:45
Fix for 714106 is apparently incomplete.
dgpplain2009-02-04 23:20:33
the existing overflow protections are
only effective for repeated substrings
of length > 1.
dgpplain2009-02-05 01:14:12
Note that the original report here
is *not a bug* but a bit of compatibility.
The count values from 0x80000000 to 0xffffffff
are taken as equivalent to the values
-0x80000000 to -1 because the value is
fetched with Tcl_GetIntFromObj().

Then, given a negative count value, 
[string repeat] returns an empty string
and no error.

The later comments note the real bug,
some uncaught overflows leading to
crashes.
dgpplain2009-02-05 01:16:09
fix committed to HEAD.
backports still needed.
dgpplain2009-02-05 02:04:44
allow_comments - 1


Backported for 8.5.7.  Not buggy in 8.4. branch.
Log in (anonymous is fine) to add a comment.