Artifacts Associated With Ticket 3e0a2d99f3
Ticket change [2c264fd455] (rid 167927) by dgp on 2018-12-12 14:06:27:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- 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. - foundin initialized to: "9.0a0"
- is_private initialized to: "0"
- login: "dgp"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "dgp"
- subsystem initialized to: "10. Objects"
- title initialized to: "[string first] failures on 32-bit platforms"
- type initialized to: "Bug"
Ticket change [507a281b19] (rid 167928) by dgp on 2018-12-12 14:06:47:
- assignee changed to: "jan.nijtmans"
- login: "dgp"
- mimetype: "text/plain"
Ticket change [f713223d6e] (rid 167929) by dgp on 2018-12-12 14:10:20:
- 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.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [4ee43d5d5c] (rid 167936) by sebres on 2018-12-12 19:25:12:
- 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).
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [22623ea8e5] (rid 167980) by jan.nijtmans on 2018-12-12 20:29:03:
- closedate changed to: "2458465.35351696"
- closer changed to: "jan.nijtmans"
- icomment:
Thanks for noticing and fixing this! Merged to trunk now, with little change: The new function moved to tclInt.h
- login: "jan.nijtmans"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- severity changed to: "Important"
- status changed to: "Closed"
Ticket change [dead274157] (rid 167982) by jan.nijtmans on 2018-12-12 20:45:50:
- closer changed to: "nobody"
- icomment:
I'll have a look at the remaining examples too. Thanks!
- login: "jan.nijtmans"
- mimetype: "text/plain"
- resolution changed to: "None"
- status changed to: "Open"
Ticket change [7a81b8b23b] (rid 167985) by sebres on 2018-12-13 07:48:44:
- 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.
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [135d0758cf] (rid 167986) by jan.nijtmans on 2018-12-13 08:56:50:
- 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.
- login: "jan.nijtmans"
- mimetype: "text/plain"
- icomment:
Ticket change [b58a70251d] (rid 167989) by sebres on 2018-12-13 09:44:25:
- 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.
- login: "sebres"
- mimetype: "text/plain"
- icomment:
Ticket change [9944fa891c] (rid 167995) by jan.nijtmans on 2018-12-13 21:17:30:
- closedate changed to: "2458466.38715941"
- closer changed to: "jan.nijtmans"
- 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
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [ab4d2eb6b0] (rid 168001) by sebres on 2018-12-14 13:19:16:
- closedate changed to: "2458467.05505056"
- closer changed to: "sebres"
- 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>
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
Ticket change [c6998a6de8] (rid 168278) by sebres on 2019-01-15 12:43:22:
- closedate changed to: "2458499.03012095"
- 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).
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
Ticket change [e3992be268] (rid 168301) by jan.nijtmans on 2019-01-16 20:16:41:
- closedate changed to: "2458500.34492203"
- closer changed to: "jan.nijtmans"
- icomment:
Thank you, sebres, for those fixes! It's appreciated!
- login: "jan.nijtmans"
- mimetype: "text/plain"