Skip to content
Tcl Source Code History Of Ticket f04e9b1304
Login

History Of Ticket f04e9b1304

Artifacts Associated With Ticket f04e9b1304

  1. Ticket change [72eaf52288] (rid 254584) by serhiy.storchaka on 2026-06-25 07:41:28:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-markdown"
    4. comment initialized to:
      ## Problem
      
      `Tcl_UtfToUpper/Lower/Title()` overrun their in-place buffer and crash on a **genuine
      4-byte UTF-8** non-BMP character (not Tcl's internal surrogate-pair form):
      
      ```c
      char buf[64] = "\xF4\x8F\xBF\xBF";   /* U+10FFFF */
      Tcl_UtfToTitle(buf);                 /* SIGSEGV */
      ```
      
      No pure-Tcl reproducer exists — script ingestion decodes to the surrogate-pair form first,
      which is safe. It only bites an embedder that passes canonical UTF-8 to the C API. Tk does
      exactly that when it title-cases a class name during init, which is how CPython crashes:
      `tkinter.Tk(className='\U0010FFFF')` (gh-126219).
      
      ## Cause
      
      `generic/tclUtf.c`. The guard meant to prevent in-place growth is
      
      ```c
      if (len < UtfCount(Char)) memmove(dst, src, len);   /* keep original */
      else dst += TclUCS4ToUtf(Char, dst);                /* write converted */
      ```
      
      For a 4-byte input, `len == 4` but `UtfCount()` returns **3** for a non-BMP character (its
      `return 4` is under `#if TCL_UTF_MAX > 3`), while `TclUCS4ToUtf()` actually writes **6**
      bytes (a surrogate pair). So `4 < 3` is false, 6 bytes are written over the 4-byte slot,
      `dst` overtakes `src`, the NUL is clobbered, and the loop runs off the buffer.
      
      ## Fix
      
      Make `UtfCount()` return the true size in a `TCL_UTF_MAX=3` build:
      
      ```c
      #if TCL_UTF_MAX > 3
          if (((unsigned)(ch - 0x10000) <= 0xFFFFF)) {
      	return 4;
          }
      #else
          if (((unsigned)(ch - 0x10000) <= 0xFFFFF)) {
      	/* A non-BMP character is stored as a 2 x 3-byte surrogate pair. */
      	return 6;
          }
      #endif
          return 3;
      ```
      
      Now `4 < 6` is true: the genuine-4-byte character is passed through unchanged (in-place
      conversion can't grow it safely), while the surrogate-pair form (`len == 6`) still
      converts. No change for `TCL_UTF_MAX > 3`.
      
    5. foundin initialized to: "8.6 (`TCL_UTF_MAX=3`, the default)"
    6. is_private initialized to: "0"
    7. login: "serhiy.storchaka"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "c62cfa96d21fcf0294bdb27e141b4604475a3f46"
    10. resolution initialized to: "None"
    11. severity initialized to: "Important"
    12. status initialized to: "Open"
    13. submitter initialized to: "serhiy.storchaka"
    14. subsystem initialized to: "- New Builtin Commands"
    15. title initialized to:
      Crash in Tcl_UtfToUpper/Lower/Title on a genuine 4-byte UTF-8 character
      
    16. type initialized to: "Bug"
  2. Add attachment "tcl86-utfcount-nonbmp-crash.patch" [6159f57da2] (rid 254585) by serhiy.storchaka on 2026-06-25 07:42:55.

  3. Ticket change [f1668d9b4b] (rid 254624) by oehhar on 2026-06-29 08:15:37:

    1. icomment:
      This is 8.6 which is end of life.
      
      Someone may nevertheless apply the patch.
      Give a sign if you want commit rights to do it on your own.
      
      Thanks for all,
      Harald
      
    2. login: "oehhar"
    3. mimetype: "text/x-fossil-wiki"
    4. username: "oehhar"
  4. Ticket change [476081d4ed] (rid 254625) by dgp on 2026-06-29 14:06:41:

    1. icomment:
      
      I'm not convinced over commit rights for purpose of continuing development
      of Tcl 8.  I don't think fossil has per-branch permissions.  Isn't it a
      better idea for folks who want to adopt Tcl 8 to make their own fork
      repository?
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  5. Ticket change [092616596c] (rid 254626) by oehhar on 2026-06-30 07:31:20:

    1. icomment:
      I tihnk, it is a good idea to merge patches to core-8-6-branch.
      It might be helpful for someone...
      Sergey still puts patches in 8.5...
      
      And the alternative is a github fork what I want to avoid.
      
      Serhiy comes from tkinter and reported, that a lot is still on 8.6, as 9.0 migration just started in new linux distributions.
      
      I find it a good think if we get tkinter people in. They have different interest and don't know fossil, so any help is appreciated.
      
      Thanks for all,
      Harald
      
    2. login: "oehhar"
    3. mimetype: "text/x-fossil-wiki"
    4. username: "oehhar"
  6. Ticket change [967f9938ba] (rid 254647) by jan.nijtmans on 2026-06-30 12:30:35:

    1. icomment:
      > I tihnk, it is a good idea to merge patches to core-8-6-branch
      
      I have no problem doing that, for trivial fixes like this one.
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  7. Ticket change [02667bc0c7] (rid 254648) by jan.nijtmans on 2026-06-30 12:33:01:

    1. assignee changed to: "jan.nijtmans"
    2. closedate changed to: "2461222.0229352429"
    3. closer changed to: "jan.nijtmans"
    4. icomment:
      Fixed [8fdf2f999ce788ba|here]
      
      Will (most likely) never land in an official release
      
    5. login: "jan.nijtmans"
    6. mimetype: "text/x-fossil-wiki"
    7. resolution changed to: "Fixed"
    8. status changed to: "Closed"