Skip to content
Tcl Source Code History Of Ticket 3e0a2d99f365c035
Login

History Of Ticket 3e0a2d99f365c035

Artifacts Associated With Ticket 3e0a2d99f365c035

  1. Ticket change [2c264fd455] (rid 167927) by dgp on 2018-12-12 14:06:27:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      First reported by "de" on the chat: http://paste.tclers.tk/4877
      
      ==== string-4.12.0 string first, start index FAILED
      ==== Contents of test case:
      
          run {string first \u7266 abc\u7266x 4}
      
      ---- Result was:
      4294967295
      ---- Result should have been (exact matching):
      -1
      ==== string-4.12.0 FAILED
      
      
      
      ==== string-4.8.1 string first FAILED
      ==== Contents of test case:
      
          run {string first "" x123xx345xxx789xxx012}
      
      ---- Result was:
      4294967295
      ---- Result should have been (exact matching):
      -1
      ==== string-4.8.1 FAILED
      
      
      
      ==== string-4.12.1 string first, start index FAILED
      ==== Contents of test case:
      
          run {string first \u7266 abc\u7266x 4}
      
      ---- Result was:
      4294967295
      ---- Result should have been (exact matching):
      -1
      ==== string-4.12.1 FAILED
      
      First fails with http://core.tcl.tk/tcl/info/1f55c24720
      
      But that appears to be new testing exposing an existing problem.
      
      TclStringFirst() on trunk returns size_t, but also needs to return
      the literal value -1 to signal 'not found'. That's not cleanly consistent.
      
      The caller then takes the result as input to Tcl_NewWideIntObj().
      On 32-bit systems, wide is larger than size_t and we get conversion
      to the wrong value.
      
    5. foundin initialized to: "9.0a0"
    6. is_private initialized to: "0"
    7. login: "dgp"
    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: "dgp"
    13. subsystem initialized to: "10. Objects"
    14. title initialized to: "[string first] failures on 32-bit platforms"
    15. type initialized to: "Bug"
  2. Ticket change [507a281b19] (rid 167928) by dgp on 2018-12-12 14:06:47:

    1. assignee changed to: "jan.nijtmans"
    2. login: "dgp"
    3. mimetype: "text/plain"
  3. Ticket change [f713223d6e] (rid 167929) by dgp on 2018-12-12 14:10:20:

    1. icomment:
      
      "de" goes on to credit "emiliano"
      
      I'm just happy someone is testing 32-bit systems, and I hope it would happen more often.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  4. Ticket change [4ee43d5d5c] (rid 167936) by sebres on 2018-12-12 19:25:12:

    1. icomment:
      First shot in [d7843f5d69] closes the issue, but introduces another problem:  `string first` can't return a value larger that INT_MAX (on x64 platform) anymore,
      and trunk is pointed in that direction.
      
      There is another fix [080ecbe60a] as branch [./timeline?r=fix-3e0a2d99f3-str-first-x86-x64|fix-3e0a2d99f3-str-first-x86-x64] solves it for both platform.
      
      BTW. As discussed on chat there are several another issues on 32-bit platform regarding the indices as well as [../tips/doc/trunk/tip/502.md|TIP#502]:
      
      - TclGetIntForIndexM seem to have a bug for cases like<br/>
        `string first a aaa 4294967295` because it results in 0 and not -1 on x86.
      
      - looks like unexpected result (esp. after TIP 502 got merged):<br/>
        `string last a aaa -1` or `string last a aaa end-5` produce 2<br/>
        I meant as opposite to `string first a aaa 5` and `string first a aaa end+1` (where both results to -1).
      
    2. login: "sebres"
    3. mimetype: "text/x-fossil-wiki"
  5. Ticket change [22623ea8e5] (rid 167980) by jan.nijtmans on 2018-12-12 20:29:03:

    1. closedate changed to: "2458465.35351696"
    2. closer changed to: "jan.nijtmans"
    3. icomment:
      Thanks for noticing and fixing this!  Merged to trunk now, with little change: The new function moved to tclInt.h
      
    4. login: "jan.nijtmans"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. severity changed to: "Important"
    8. status changed to: "Closed"
  6. Ticket change [dead274157] (rid 167982) by jan.nijtmans on 2018-12-12 20:45:50:

    1. closer changed to: "nobody"
    2. icomment:
      I'll have a look at the remaining examples too. Thanks!
      
    3. login: "jan.nijtmans"
    4. mimetype: "text/plain"
    5. resolution changed to: "None"
    6. status changed to: "Open"
  7. Ticket change [7a81b8b23b] (rid 167985) by sebres on 2018-12-13 07:48:44:

    1. icomment:
      I had to fix the "little change" partially back again (otherwise this had caused a dual invocation of TclStringFirst/TclStringLast), see [e1b31151e5].<br/>
      In order to prevent this (or even some UB's), please always try to avoid the usage of macro's as functions, if inside it the parameters are used multiple times.
      
    2. login: "sebres"
    3. mimetype: "text/x-fossil-wiki"
  8. Ticket change [135d0758cf] (rid 167986) by jan.nijtmans on 2018-12-13 08:56:50:

    1. icomment:
      > (otherwise this had caused a dual invocation of TclStringFirst/TclStringLast)
      
      I don't think my macro causes a dual invocation at all ;-)   Please have another look.
      
      The trick is to do a +1, then cast to (Tcl_WideInt), followed by a -1.  That's more efficient than an if-statement.
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/plain"
  9. Ticket change [b58a70251d] (rid 167989) by sebres on 2018-12-13 09:44:25:

    1. icomment:
      Hmm, right... Just as I've noticed some compiler warning (I think it was gcc 7.x or 8.0, -m32 -O3) I had take a look into diff here in fossil-ui and saw the macro, but overlooked the change with you smarter +1-1 casting part, as it was hidden (because of scrollbars).
      So sorry for the wrong reprovals from my side ;)
      
      Although I think the compiler will optimize it, anyway you are right, thus reverted back to your revision, with a little change from me, (you've forgot a cast to (size_t)(value) by increment in macro, if somewhere later another type as size_t will be used as value).
      
      Thanks.
      
    2. login: "sebres"
    3. mimetype: "text/plain"
  10. Ticket change [9944fa891c] (rid 167995) by jan.nijtmans on 2018-12-13 21:17:30:

    1. closedate changed to: "2458466.38715941"
    2. closer changed to: "jan.nijtmans"
    3. icomment:
      Should be fixed now in core-8-branch and trunk.
      
      Still TODO: Handle indexes > 2Gb, but that's not what this bug is about
      
    4. login: "jan.nijtmans"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
  11. Ticket change [ab4d2eb6b0] (rid 168001) by sebres on 2018-12-14 13:19:16:

    1. closedate changed to: "2458467.05505056"
    2. closer changed to: "sebres"
    3. icomment:
      BTW, we don't need to handle indexes with offset > 2Gb, because allocating of single block with this size is impossible in 32-bit process. Let alone there is no 32-bits platforms (at least x86/ARM), that allow you to have common process memory > 2Gb at all.
      Just try:
      <code><pre style="padding-left:10pt">
      % string repeat " " 0x7fffffff
      string size overflow, out of memory allocating 2147483648 bytes
      </pre></code>
      
    4. login: "sebres"
    5. mimetype: "text/x-fossil-wiki"
  12. Ticket change [c6998a6de8] (rid 168278) by sebres on 2019-01-15 12:43:22:

    1. closedate changed to: "2458499.03012095"
    2. icomment:
      Found new tests failed for similar reasons on 32-bit systems (even on border case unsigned (size_t)-1 to signed wide-int conversion):
      
      lset (16.5, 16.6, 16.7) - failed with out of range instead of set element.
      string (6.102.0/1, 31.9a.0/1) - failed with 4294967295 instead of -1.
      
      Fixed now in [175e053939] and [8a67f59280].
      
      Additionally [8a67f59280] introduces now new internal macro <code>TclWideIntFromSize</code> for correct conversion of size_t to wide-int to consider platform-related "negative" value ((size_t)-1), if wide-int and size_t have different dimensions (e. g. on 32-bit platforms).
      
    3. login: "sebres"
    4. mimetype: "text/x-fossil-wiki"
  13. Ticket change [e3992be268] (rid 168301) by jan.nijtmans on 2019-01-16 20:16:41:

    1. closedate changed to: "2458500.34492203"
    2. closer changed to: "jan.nijtmans"
    3. icomment:
      Thank you, sebres, for those fixes! It's appreciated!
      
    4. login: "jan.nijtmans"
    5. mimetype: "text/plain"