Skip to content
Tcl Source Code History Of Ticket f443140a85
Login

History Of Ticket f443140a85

Artifacts Associated With Ticket f443140a85

  1. Ticket change [a5247a0e52] (rid 182643) by jan.nijtmans on 2020-04-27 16:48:09:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      When hunting for [27944a3661], it has ben apparent that some people expect that Tcl_UtfCharComplete() can be used to protect Tcl_UtfNext() calls for overflowing
      when the string is not 0-terminated. This has always been true, but not any more with TIP #389. Since such a connection was never documented, no problem: We shouldn't document something that isn't true.
      
      However, there is a problem with TIP #542: According to the current documentation of Tcl_UtfPrev:
      <pre>
      When \fIsrc\fR is greater than \fIstart\fR, it
      always returns a pointer less than \fIsrc\fR and greater than or
      equal to (\fIsrc\fR - \fBTCL_UTF_MAX\fR)
      </pre>
      
      This is not true anymore for Tcl 8.7+. Either change TCL_UTF_MAX to 4 (as they can step over 4 bytes), or make Tcl_UtfNext()/Tcl_UtfPrev() step twice for Characters > 0xFFFF
      
      This ticket is meant to expore the second possibility. If it fails we can always change the documentation. If it works, then Tcl_UtfCharComplete() can be used - again - to protect Tcl_UtfNext calls.
      
    5. is_private initialized to: "0"
    6. login: "jan.nijtmans"
    7. priority initialized to: "5 Medium"
    8. resolution initialized to: "None"
    9. severity initialized to: "Minor"
    10. status initialized to: "Open"
    11. submitter initialized to: "jan.nijtmans"
    12. subsystem initialized to: "44. UTF-8 Strings"
    13. title initialized to:
      connection between Tcl_UtfNext/Tcl_UtfPrev and Tcl_UtfCharComplete()
      
    14. type initialized to: "RFE"
  2. Ticket change [74a3ed41ad] (rid 182644) by jan.nijtmans on 2020-04-27 16:48:22:

    1. assignee changed to: "jan.nijtmans"
    2. login: "jan.nijtmans"
    3. mimetype: "text/plain"
  3. Ticket change [3e6efbfe3d] (rid 182650) by dgp on 2020-04-27 18:34:00:

    1. icomment:
      
      Fully support exploring our options here. Happy we're working through these
      rough edges during the alpha development.
      
      One request.  The docs for Tcl_UtfNext have always instructed, "The
      caller must not ask for the next character after the last character in
      the string if the string is not terminated by a null character."  I think the
      inference to use Tcl_UtfCharComplete() as the tool for following this
      instruction has been reasonable, but if we're deciding that capability is
      dispensable, the documentation should include explicit advice about
      what callers of Tcl_UtfNext are supposed to do instead.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  4. Ticket change [778d02e892] (rid 182682) by jan.nijtmans on 2020-04-28 08:29:17:

    1. icomment:
      I see what's going on: The current documentation can be interpreted various ways, that should be clarified. For example:
      
      <pre>
      test utf-7.40.0 {Tcl_UtfPrev -- overlong sequence}  {testutfprev tip389} {
          testutfprev A\xF0\x90\x80\x80 4
      } 3
      </pre>
      
      So, we have a valid 4-byte UTF-8 sequence. The pointer is on the last byte of it.
      
      Currently, the output is "3". Common sense in this case says it should jump to the first byte of the sequence. So, the output should be "1". But ... since - in this branch - we want to
      make Tcl_UtfPrev() symmetric with Tcl_UtfNext(), it could also make sence to let
      it jump to the second byte of the sequence so "2".
      
      So, Don, would you expect "1" here (jump to the beginning of the sequence) or "2"
      (jump to the second byte".   I'll have to think on that too.....
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  5. Ticket change [a437cb45d4] (rid 182687) by jan.nijtmans on 2020-04-28 10:15:38:

    1. icomment:
      Thinking about it, Tcl_UtfPrev() should - whenever possible do to other restrictions - return a pointer to the first byte of the sequence. If TCL_UTF_MAX=3 and Tcl_UtfPrev() encounters 3 trail-bytes, we have the restriction that Tcl_UtfPrev() cannot jump more that TCL_UTF_MAX bytes. So, then it will jump TCL_UTF_MAX bytes, and another call to Tcl_UtfPrev() will be needed to get in sync with the byte sequence again. Something like that should be documented.
      
      Well, accepting the (possible) description above, there are 10 test-cases violating that. Those are:
      
         * utf-7.10.0
      
         * utf-7.10.2
      
         * utf-7.10.4
      
         * utf-7.15.0
      
         * utf-7.15.2
      
         * utf-7.15.4
      
         * utf-7.40.0
      
         * utf-7.41.0
      
         * utf-7.48.2
      
         * utf-7.48.4
      
      All of those involve valid 4-byte sequences where the pointer is not on a character border.
      
      So, still work to do to fix this.
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  6. Ticket change [e9f5910084] (rid 182696) by dgp on 2020-04-28 17:38:19:

    1. icomment:
      You ask about test utf-7.40.0 .  Note that it is paired with the test utf-7.40.1.
      The pair of tests are meant to cover the changing behavior of Tcl through different
      releases.
      
      The first test is constrained to "ucs2" which in this case is meant to  indicate a Tcl
      interpreter like the default build of Tcl 8.5 where 4 byte sequences are not recognized
      as valid at all.  In that circumstance, the byte sequence \xF0\x90\x80\x80 encodes
      the character sequence
          U+00F0 U+0090 U+0080 U+0080
      and we are pointed at the 4th of those 4 characters.  The correct previous character
      is the third one, and the test properly expects the result "3".
      
      We may regret that history, but it is the documented and expected behavior of
      our released products.  This test among others will help us not release a Tcl 8.5.20
      that is at odds with Tcl 8.5.19.  Folks who cannot abide this nonconformance in
      our old release lines are welcome to move forward to the first release line that meets
      their standards. We have several to choose from.
      
      The companion test is constrained "fullutf" which in this case is meant to indicate
      a Tcl interpreter where 4-byte sequences are recognized.  The expected result of
      this test is "1", just as you call for.
      
      I cannot think of any reason why I would hope to see "2" as the answer.
      
      Hmmmm.... now that I look again at your comment, you have a test utf-7.40.0
      with a constraint "tip389". That is not correct, and it doesn't match the content of
      any of the main dev branches.  Branches 8.5 and 8.6 are as I describe, and
      branch 8.7 does not yet have this testing regime brought forward (Still working
      on that, sorry). Branches 8.7 and 9 have no test utf-7.40.0 at all yet.
      
      Does that help?
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  7. Ticket change [3d8295396a] (rid 182697) by dgp on 2020-04-28 17:49:27:

    1. icomment:
      
      Only some of your followup list of tests match up with the contents of
      Tcl 8.5 or 8.6 branches, and in those cases are constrained ucs2.
      
      Looks to me like the only issue here is getting the branches in sync (I am
      working on it bit by bit. Trying to be careful. Logging and fixing bugs as I go),
      and maybe some work on getting the right constraints in the right places.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  8. Ticket change [d3857b750b] (rid 182698) by dgp on 2020-04-28 18:06:02:

    1. icomment:
      
      Oh boy.  Now I see some of your explorations have been committed to
      the 8.5 branch.  Most unwelcome.  Now gotta defensively examine that
      and react before I can continue forward.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  9. Ticket change [3ff2a63f94] (rid 182712) by jan.nijtmans on 2020-04-28 19:32:16:

    1. icomment:
      > Now I see some of your explorations have been committed to the 8.5 branch.
      
      Your're welcome to assure yourself that it doesn't have any effect on TCL_UTF_MAX=3.
      
      The TCL_UTF_MAX=4 branch should be kept as much as possible up to date with the "fullutf" feature in later branches: With TCL_UTF_MAX=4 there are no surprises, so whatever tests are devised and whatever bug-fixes are devised in later branches, they all should be harmless to be backported. If not, let me know!
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/plain"
  10. Ticket change [599a587156] (rid 182722) by jan.nijtmans on 2020-04-28 19:48:52:

    1. icomment:
      B.T.W: I am not happy about your "readlimit" test-cases, utf-6.96 and up. You used it to explore the cases where Tcl_UtfNext() reads more bytes than Tcl_UtfCharComplete(). We already know that there is no relation between those to (I am exploring the possibility to create a relation, because I would like that too).  As soon as you merge those test-cases up to 8.7, it will only mean more meaningless work, keeping the test-cases passing.
      
      Also I'm not happy about removing the --bytestring option:  I want to see clearly in the test-case whether the testcase involves invalid byte-sequences or not. If no, then it would be better to use \xXX \uXXXX or \UXXXXXX syntax. The reason: We cannot forgive changes in handling of valid sequences, but there is some room in invalid sequences (remember the overflow/underflow changes in 4-byte sequences, the really change output, even in Tcl 8.5!)
      
      So, please don't merge testcases utf-6.96 and up to 8.7, better even remove them (and keep them in your own branch if you like).
      
      Apparently I don't understand completely how you name testConstraints, but I'm not very picky on this naming. If you like to rename them, I don't mind much.
      
      Anyway, thanks for your effort streamlining the test-cases in all branches: that's very welcome! I'm trying to the same.
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/plain"
  11. Ticket change [d1a3677699] (rid 182723) by dgp on 2020-04-28 19:50:04:

    1. icomment:
      Please forgive the grumpiness in my last comment. Just a reaction to a change
      in my plans for the day.
      
      As we can both see now, the changes were largely good ones, some others
      mostly harmless, and the few harms easily corrected.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  12. Ticket change [1e5bb0d442] (rid 182724) by dgp on 2020-04-28 20:01:37:

    1. icomment:
      
      Our two disagreements about [testutfnext] are related.
      
      If I am going to test how callers of Tcl_UtfNext handle the situation
      when asked to advance beyond the end of a counted string, I need
      the ability to give the testing command a counted string, and that meant
      adding another argument, "numBytes".
      
      When I went to add that option, and found the command already with
      processing for an optional "--bytestring" it made the task more difficult.
      So I asked myself what callers needed this option and when the answer
      was that no caller needed this distinction, I eliminated it.
      
      Now that I see your aim is providing an informational clue to the code reader,
      I will try to bring something back in to provide that before intruding on
      the 8.7 branch  with it.
      
      For now, I am on section 25, not 6, roughly working backwards.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  13. Ticket change [8deddf1577] (rid 182742) by jan.nijtmans on 2020-04-28 20:52:36:

    1. icomment:
      Just a little demo [bb68f27f5b47ad4f]
      
      With a little adaption, "testutfnext" can check whether it overflows the give bytes. For example, try to remove the \x00 from the end of utf-6.9:
      
      <pre>
      ==== utf-6.9 Tcl_UtfNext FAILED
      ==== Contents of test case:
          testutfnext -bytestring \xA0
      ---- Test generated error; Return code was: 1
      ---- Return code should have been one of: 0 2
      ---- errorInfo: Tcl_UtfNext is not supposed to read src[end]
          while executing
      "testutfnext -bytestring \xA0"
          ("uplevel" body line 2)
          invoked from within
      "uplevel 1 $script"
      ---- errorCode: NONE
      ==== utf-6.9 FAILED
      </pre>
      
      This way, we don't need new test-cases with a "numbytes" argument. In the same way, "testutfnext" tests whether src[-1] is read, but we know it doesn't
      
      Hope you like it!
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  14. Ticket change [9e21f1eb6b] (rid 182780) by jan.nijtmans on 2020-04-29 11:26:10:

    1. icomment:
      Let me describe a little bit how I see those testcases. For example utf-2.9.[012]
      
      [https://core.tcl-lang.org/tcl/artifact?ln=117-125&name=b7a8d0dbc9b5df6e]
      
      We want to test "string length" with 4-byte sequences. The "ucs2" selector is used for Tcl 8.5, which doesn't know anything about 4-byte sequences. So test-case utf-2.9.0 handles that.
      
      Builds knowing UCS4 can use the \UXXXXX escape sequence to generate 4-byte sequences. Testcase utf-2.9.1 does that. No need for "testbytestring" here.
      
      Builds not knowing UCS4 can use surrogate pairs. This even works on Tcl 8.5, but there it is actually a different test-case. No problem. This way we have 3 test-cases covering as much situations as possible.
      
      Hope this makes it a little bit more clear
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  15. Ticket change [6adab07c4b] (rid 192624) by jan.nijtmans on 2021-03-18 13:33:31:

    1. closedate changed to: "2459292.06494949"
    2. closer changed to: "jan.nijtmans"
    3. foundin changed to: "8.7"
    4. icomment:
      A side effect of [https://core.tcl-lang.org/tips/doc/trunk/tip/575.md|TIP #575] is that now - for all versions of Tcl - Tcl_UtfCharComplete() can be used to protect Tcl_UtfNext(). So we can close this ticket.
      
    5. login: "jan.nijtmans"
    6. mimetype: "text/x-fossil-wiki"
    7. resolution changed to: "Fixed"
    8. status changed to: "Closed"