compilation of incr command is broken on wide constant offset by int overflow
Closed / Fixed7179c6724cd38271a771343f80197b1fc57315adCreated 2 years agoUpdated 2 years ago
Descriptionwiki2024-08-12 12:48:06
Compilation of incr command (with immutable offset, as
INST_INCR_*_IMM) seems to be broken on wide constant offset by int overflow.
Non-compiled or dynamic offset (compiled as INST_INCR_* instructions without _IMM suffix) work as expected:
% set i 0; incr i 0xffffff80
4294967168
% set i 0; incr i 0xffffff81
-127
% set i 0; incr i 0xffffffff
-1
% set i 0; set cmd incr; $cmd i 0xffffffff
4294967295
% set i 0; incr i [set x 0xffffffff]
4294967295
% set i 0; incr i 4294967169
-127
% set i 0; incr i 4294967295
-1
My fork doesn't have this bug, so I'll try to backport the fix.
sebres Ticket [7179c6724c]: 5 changes
[History diff]2024-08-12 12:50:32
sebreswiki2024-08-12 13:39:02
Fixed:
- 8.5 - [068a8b152e2da1e0]
- 8.6 - [e2f55d60603a87a3]
- 8.7/9.0 - [cbabbeed5105d882] / [8f8b3d2903776a4a]
sebresmarkdown2024-08-12 13:54:03
By the way, the fix was minimalistic, in opposite to my fix in fork, that uses safe TclGetSignedIntFromObj routine (tcl seems not to have yet), which wouldn't success by overflow, and since the code is full with Tcl?_?GetIntFromObj, maybe it'd be time for larger review (to prevent ugly unintended overflows like that everywhere).
sebres Ticket [7179c6724c]: 4 changes
[History diff]2024-08-12 14:27:29
Log in (anonymous is fine) to add a comment.