Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Tcl_Merge(): signed integer overflow

Closed / Fixede32a44e2e49e5fe3a21162db2b2dd915ba8589d5Created 4 years agoUpdated 4 years ago
Descriptionwiki2022-10-02 11:26:50
Example script (not much usage of Tcl_Merge() in core Tcl):
set 1k_spaces [string repeat { } [::tcl::mathop::<< 1 10]]
set 1M_spaces [string repeat $1k_spaces [::tcl::mathop::<< 1 10]]
set 1G_spaces [string repeat $1M_spaces [::tcl::mathop::<< 1 10]]

testpanic $1G_spaces $1G_spaces

Output containing UBSan error, which the attached patch avoids:

$ ./tcltest script.tcl
(some time passes)
tcl/generic/tclUtil.c:1596:14: runtime error: signed integer overflow: 1073741826 + 1073741826 cannot be represented in type 'int'
max size for a Tcl value (2147483647 bytes) exceeded
(tcltest aborts, though before TestpanicCmd() can directly call Tcl_Panic().)
Referenced by1
jan.nijtmanswiki2022-10-06 10:23:32

Should be fixed [here]

Log in (anonymous is fine) to add a comment.

Attachments: