Skip to content
Tcl Source Code History Of Ticket 0e8fd6c6d5
Login

History Of Ticket 0e8fd6c6d5

Artifacts Associated With Ticket 0e8fd6c6d5

  1. Ticket change [58e788fd80] (rid 199480) by chrstphrchvz on 2022-03-22 02:02:17:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      …causing <tt>stringAlloc(STRING_MAXCHARS)</tt> or similar to eventually lead to a crash or noticeable memory corruption. Example:
      
      <pre>
      set a &#91;string repeat a 1073741820&#93;
      # crash when attempting to create string with longest possible unicode rep and no string rep
      set aa &#91;string replace $a 0 0 $a &#93;
      </pre>
      
      After <tt>TCLFLEXARRAY</tt> ([29540d10c4]) was introduced, <tt>STRING_MAXCHARS</tt> was updated ([3a6a0399ad]), but the <tt>…- 1…</tt> seems to be misplaced (it currently makes no difference in the numerator of the expression): see attached patch. <tt>STRING_MAXCHARS</tt> apparently should return 1 less than what it currently does (i.e. 2147483638 rather than 2147483639, for 32-bit <tt>int</tt> and 16-bit <tt>Tcl_UniChar</tt>).
      
      To my knowledge there are no similar issues for other structures using <tt>TCLFLEXARRAY</tt>.
      
    5. foundin initialized to: "core-8-6-branch"
    6. is_private initialized to: "0"
    7. login: "chrstphrchvz"
    8. priority initialized to: "5 Medium"
    9. resolution initialized to: "None"
    10. severity initialized to: "Minor"
    11. status initialized to: "Open"
    12. submitter initialized to: "chrstphrchvz"
    13. subsystem initialized to: "10. Objects"
    14. title initialized to: "(unsigned)STRING_SIZE(STRING_MAXCHARS) is 0"
    15. type initialized to: "Patch"
  2. Add attachment "string-maxchars-oboe.diff" [86c3335bd7] (rid 199481) by chrstphrchvz on 2022-03-22 02:02:42.

  3. Ticket change [bf5f854885] (rid 199482) by chrstphrchvz on 2022-03-22 02:10:14:

    1. icomment:
      Just an observation: when built using Clang 13.0.1 AddressSanitizer (<tt>-fsanitize=address</tt>) on macOS, running this example triggers an invalid write in <tt>realloc(ptr, 0)</tt>; the address is just before <tt>ptr</tt>, i.e. likely in the ASAN chunk header, so I wonder if this is an ASAN bug.
      
      <tt>realloc(ptr, 0)</tt> (where <tt>ptr != NULL</tt>) is expected to become undefined behavior in C23, however. Should Tcl try preventing this from happening in e.g. <tt>Tcl_Realloc()</tt>, <tt>ckrealloc()</tt>, etc.?
      
    2. login: "chrstphrchvz"
    3. mimetype: "text/x-fossil-wiki"
  4. Ticket change [5bb96271ea] (rid 199548) by chrstphrchvz on 2022-03-22 18:41:41:

    1. icomment:
      The ASan flag <tt>allocator_frees_and_returns_null_on_realloc_zero</tt> is enabled by default, so this Tcl issue effectively triggers a double free. The problem seems to be that ASan is not detecting/reporting double frees for at least some large allocations.
      
    2. login: "chrstphrchvz"
    3. mimetype: "text/x-fossil-wiki"
  5. Ticket change [f588184979] (rid 199558) by jan.nijtmans on 2022-03-22 20:09:07:

    1. assignee changed to: "jan.nijtmans"
    2. closedate changed to: "2459661.3396736"
    3. closer changed to: "jan.nijtmans"
    4. icomment:
      Good catch!  Should be fixed now.
      
      Thanks for the report and the patch!
      
    5. login: "jan.nijtmans"
    6. mimetype: "text/x-fossil-wiki"
    7. resolution changed to: "Fixed"
    8. status changed to: "Closed"
  6. Ticket change [58c547008c] (rid 199590) by chrstphrchvz on 2022-03-24 01:01:51:

    1. closedate changed to: "2459662.54296211"
    2. closer changed to: "chrstphrchvz"
    3. icomment:
      ASan issue reported: [https://github.com/google/sanitizers/issues/1502]
      
    4. login: "chrstphrchvz"
    5. mimetype: "text/x-fossil-wiki"