Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: a4b175c4b67d96dc51ef222f005bef783160a44c6b50be620852bf65b790e9c1
Ticket: e32a44e2e49e5fe3a21162db2b2dd915ba8589d5
Tcl_Merge(): signed integer overflow
User & Date: chrstphrchvz on 2022-10-02 11:26:50
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    Example script (not much usage of <tt>Tcl_Merge()</tt> in core Tcl):
    
    <blockquote><pre>
    set 1k_spaces &#91;string repeat { } &#91;::tcl::mathop::&lt;&lt; 1 10&#93;&#93;
    set 1M_spaces &#91;string repeat $1k_spaces &#91;::tcl::mathop::&lt;&lt; 1 10&#93;&#93;
    set 1G_spaces &#91;string repeat $1M_spaces &#91;::tcl::mathop::&lt;&lt; 1 10&#93;&#93;
    
    testpanic $1G_spaces $1G_spaces
    </pre></blockquote>
    
    Output containing UBSan error, which the attached patch avoids:
    
    <blockquote><pre>
    $ ./tcltest script.tcl
    </pre>
    (some time passes)
    <pre>
    <span style="font-weight:bold">tcl/generic/tclUtil.c:1596:14: <span style="color:firebrick">runtime error:</span> signed integer overflow: 1073741826 + 1073741826 cannot be represented in type 'int'</span>
    max size for a Tcl value (2147483647 bytes) exceeded
    </pre>
    (tcltest aborts, though before <tt>TestpanicCmd()</tt> can directly call <tt>Tcl_Panic()</tt>.)
    </blockquote>
    
  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: "14. List Object"
  14. title changed to: "Tcl_Merge(): signed integer overflow"
  15. type changed to: "Patch"