Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

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

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. 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.
    
  5. foundin changed to: "core-8-6-branch"
  6. is_private changed to: "0"
  7. login: "chrstphrchvz"
  8. priority changed to: "5 Medium"
  9. resolution changed to: "None"
  10. severity changed to: "Minor"
  11. status changed to: "Open"
  12. submitter changed to: "chrstphrchvz"
  13. subsystem changed to: "48. Number Handling"
  14. title changed to:
    signed integer overflow during expr-34.22, expr-36.22
    
  15. type changed to: "Patch"