Skip to content
Tcl Source Code History Of Ticket f5eadcbf9a
Login

History Of Ticket f5eadcbf9a

Artifacts Associated With Ticket f5eadcbf9a

  1. Ticket change [92ef8facf8] (rid 213858) by pooryorick on 2023-04-25 20:26:02:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      In various locations in the source code uninitialized data is passed to
      Tcl_UniCharToUtf() via its *buf argument.  In addition to holding the result of
      Tcl_UniCharToUtf(), since [e2278643dc330026] in 2015 *buf also serves to
      maintain the state of an ongoing surrogate character transformation, and random
      data in the uninitialized storage can cause  Tcl_UniCharToUtf() to corrupt
      data.
      
    5. is_private initialized to: "0"
    6. login: "pooryorick"
    7. priority initialized to: "5 Medium"
    8. private_contact initialized to: "2b2275eab1118e1fab0016cf1c5702893c6af86c"
    9. resolution initialized to: "None"
    10. severity initialized to: "Severe"
    11. status initialized to: "Open"
    12. submitter initialized to: "pooryorick"
    13. subsystem initialized to: "- New Builtin Commands"
    14. title initialized to:
      passing pointer to uninitialized memory leads Tcl_UniCharToUtf() to corrupt data
      
    15. type initialized to: "Bug"
  2. Ticket change [e4991f1bd6] (rid 213865) by pooryorick on 2023-04-25 20:36:50:

    1. comment changed to:
      In various locations in the source code uninitialized data is passed to
      <code>Tcl_UniCharToUtf()</code> via its <code>*buf</code> argument.  In addition to holding
      the result of <code>Tcl_UniCharToUtf()</code>, since [e2278643dc330026] in 2015
      <code>*buf</code> also serves to maintain the state of an ongoing surrogate character
      transformation, and random data in the uninitialized storage can cause
      <code>Tcl_UniCharToUtf()</code> to corrupt data.
      
    2. icomment: "Fixed in [f5eadcbf9a6b1b4c]."
    3. login: "pooryorick"
    4. mimetype: "text/x-fossil-wiki"
    5. status changed to: "Pending"
  3. Ticket change [3fd844f6af] (rid 213866) by pooryorick on 2023-04-25 20:39:18:

    1. icomment:
      A better fix would be to isolate the stateful data so that it isn't necessary to initialize the entire buffer, and an even better fix would be to use a proper structure to hold both the buffer and other pertinent information.
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
    4. resolution changed to: "Fixed"
  4. Ticket change [799f8dfc20] (rid 213867) by jan.nijtmans on 2023-04-25 20:50:50:

    1. icomment:
      This is a non-issue. In Tcl 9.0 with TCL_UTF_MAX=4, Tcl_UniCharToUtf() doesn't combine surrogates any more. You could put #ifdef's "TCL_UTF_MAX < 4" around it, otherwise this patch only costs performance without any benefit. Please don't do that (asking nicely)
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  5. Ticket change [bee6417cc4] (rid 213868) by jan.nijtmans on 2023-04-25 20:58:50:

    1. icomment:
      Example of a much better bug-report, with testcase: [95e287b956].
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
    4. severity changed to: "Minor"
  6. Ticket change [e3104d5d36] (rid 213870) by pooryorick on 2023-04-26 02:36:54:

    1. icomment:
      This is not a non-issue.  Commit [a61fef8429dfff4b] was recently moved off trunk due to the fact that it caused test format-2.19 to fail under a build of TCL_UTF_MAX = 3. This bug is the cause of that failure.  In every spot except one "TCL_UTF_MAX < 4" would not be incorrect.  I considered adding those, but I think Tcl_UniCharToUtf() is an example of the type of coding that there should be zero tolerance for, as smuggling flags and state into existing argument turns the code into a booby trap for future developers.
      See [https://web.stanford.edu/~ouster/cgi-bin/cs190-winter18/lecture.php?topic=complexity|The Nature of Complexity] by Jon Ousterhout.
        Instead, the signature of Tcl_UniCharToUtf() should be changed to explicitly support the new functionality.  Also, TCL_UTF_MAX = 3 should be removed from trunk and from Tcl 9.  It no longer serves any purpose, and is responsible for at least this bug.  For whatever reason, valgrind is not picking up on this issue.  
      
      Jan, you won't be able to create a test case for this issue, yet it is real.  After this is fixed and my commit mentioned above is reapplied to trunk, format-2.19 will be one canary for the issue.
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  7. Ticket change [981f63f81f] (rid 213871) by pooryorick on 2023-04-26 02:44:59:

    1. icomment:
      The Tcl code base has suffered a growing complexity problem in recent years, This report is just one symptom of the larger issue.  Practices like the use of novel techniques to overload function signatures, the proliferation of macros that create different code bases during preprocessing, and other contortions in the name of preserving backwards compatibility should be curtailed.
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  8. Ticket change [fdff598bc8] (rid 213873) by pooryorick on 2023-04-26 03:28:24:

    1. icomment:
      I started to enclose the calls to memset in a "TCL_UTF_MAX < 4" block as requested by Jan, but then decided against it.  This is bad practice that makes the code more brittle for future developers.  The cost of memset should be born until the code can be improved.
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  9. Ticket change [389fbe0bc9] (rid 213886) by jan.nijtmans on 2023-04-26 12:25:21:

    1. icomment:
      This doesn't give much confidence that you tested your stuff: [https://github.com/tcltk/tcl/actions/runs/4806142861/jobs/8553302123]
      
      <pre>
      utfext.test
      
      
      ==== Tcl_ExternalToUtf-ascii-414243-start-end Tcl_ExternalToUtf - ascii - 414243 - start end FAILED
      ==== Contents of test case:
      testencoding Tcl_ExternalToUtf ascii ABC {start end} {} 40
      ---- Result was:
      ok {} ABC\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF
      ---- Result should have been (exact matching):
      ok {} ABC\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF
      ==== Tcl_ExternalToUtf-ascii-414243-start-end FAILED
      ...
      Tests ended at Wed Apr 26 07:50:29 UTC 2023
      all.tcl:	Total	56303	Passed	50591	Skipped	5704	Failed	8
      </pre>
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  10. Ticket change [c61c0041b7] (rid 213887) by pooryorick on 2023-04-26 13:00:31:

    1. icomment:
      Jan, first you get defensive and call this a non-issue, then you spam
      the ticket with test results from a work-in-progress branch in an
      attempt to distrct from the real issue:  Random data in uninitialized
      memory are causing the "format-2.19" test to fail under a build of the
      pyk-Tcl_AppendObjToObj branch configured with "TCL_UTF_MAX = 3"?
      
      Did you even notice that those failing tests hard-coded a dependence on
      uninitialized data, and just need to be adjusted for the fact that the
      memory area is now initialized?
      
      I'm not in favor of the memset() solution.  I'm in favor of deleting a
      whole bunch of "TCL_UTF_MAX = 3" code.
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  11. Ticket change [a3361a4d4a] (rid 213974) by pooryorick on 2023-04-27 20:43:36:

    1. assignee changed to: "pooryorick"
    2. icomment:
      Rather than adjusting those tests I've modified the memset() calls to fill 0xff instead of 0.  Fix now applied to trunk [480c856482].
      
    3. login: "pooryorick"
    4. mimetype: "text/x-fossil-wiki"
  12. Ticket change [e3649dc9a2] (rid 214428) by pooryorick on 2023-05-03 10:40:33:

    1. closedate changed to: "2460067.94483358"
    2. closer changed to: "pooryorick"
    3. login: "pooryorick"
    4. mimetype: "text/plain"
    5. status changed to: "Closed"