Overview
| Artifact ID: | e673a77b8e1a5d0a2ddc98079f555310ecb9ccde41a5be93978c474f8301a1c8 |
|---|---|
| Ticket: | cb90038a637ed2ff8338a9fe288940bad334a822
signed integer overflow during expr-34.22, expr-36.22 |
| User & Date: | chrstphrchvz on 2022-02-17 15:24:10 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-wiki"
- comment changed to:
This command (as does test expr-34.22) triggers signed integer overflow (undefined behavior) when <tt>long</tt> is 32-bit: <blockquote><pre> % ::tcl::mathop::% -0x80000000 3 <span style="font-weight:bold">tcl/generic/tclExecute.c:6289:24:<span style="color:red"> runtime error: </span>signed integer overflow: 3 * -715827883 cannot be represented in type 'long int'</span> <span style="font-weight:bold">tcl/generic/tclExecute.c:6289:15:<span style="color:red"> runtime error: </span>signed integer overflow: -2147483648 - 2147483647 cannot be represented in type 'long int'</span> 1 </pre></blockquote> Similar issue for this command (and test expr-36.22) for 64-bit <tt>long long</tt>: <blockquote><pre> % ::tcl::mathop::% -0x8000000000000000 3 <span style="font-weight:bold">tcl/generic/tclExecute.c:8547:23:<span style="color:red"> runtime error: </span>signed integer overflow: -3074457345618258603 * 3 cannot be represented in type 'long long int'</span> <span style="font-weight:bold">tcl/generic/tclExecute.c:8547:14:<span style="color:red"> runtime error: </span>signed integer overflow: -9223372036854775808 - 9223372036854775807 cannot be represented in type 'long long int'</span> 1 </pre></blockquote> The attached patch uses the corresponding unsigned types to accommodate overflow in these edge cases.
- foundin changed to: "core-8-6-branch"
- is_private changed to: "0"
- login: "chrstphrchvz"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- severity changed to: "Minor"
- status changed to: "Open"
- submitter changed to: "chrstphrchvz"
- subsystem changed to: "48. Number Handling"
- title changed to:
signed integer overflow during expr-34.22, expr-36.22
- type changed to: "Patch"