Artifacts Associated With Ticket 76ad7aeba3
Ticket change [a93ee0f462] (rid 200907) by mistachkin on 2022-05-20 17:32:02:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
The following script show a bug in the [string is integer] sub-command: set class integer set value 18446744073709551615 string is $class $value; # should be 0 The result was "1" (incorrect) using the following check-ins running on the Linux x86_64 platform: core-8-6-branch - e7da3f4504cd9db6e28fd4ed73dae542ab7c91f4 core-8-branch - eaf93525a5d4bd519dfd68add09a3586ca0c1831
- foundin initialized to: "8.6.12"
- is_private initialized to: "0"
- login: "mistachkin"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- severity initialized to: "Important"
- status initialized to: "Open"
- submitter initialized to: "mistachkin"
- subsystem initialized to: "18. Commands M-Z"
- title initialized to: "boundary case bug in [string is integer]"
- type initialized to: "Bug"
Ticket change [289eb5dc85] (rid 200908) by mistachkin on 2022-05-20 17:42:53:
- comment changed to:
The following script shows a bug in the [string is integer] sub-command: set class integer set value 18446744073709551615 string is $class $value; # should be 0 The result was "1" (incorrect) using the following check-ins running on the Linux x86_64 platform: core-8-6-branch - e7da3f4504cd9db6e28fd4ed73dae542ab7c91f4 core-8-branch - eaf93525a5d4bd519dfd68add09a3586ca0c1831 Also, compare and contrast with the result of the following command: string is integer 18446744073709551615; # should be 0 This seems to imply that the bug involves the compiler.
- login: "mistachkin"
- mimetype: "text/plain"
- comment changed to:
Ticket change [5de8b3151b] (rid 200909) by mistachkin on 2022-05-20 17:43:52:
- comment changed to:
The following script shows a bug in the [string is integer] sub-command: set class integer set value 18446744073709551615 string is $class $value; # should be 0 The result was "1" (incorrect) using the following check-ins running on the Linux x86_64 platform: core-8-6-branch - e7da3f4504cd9db6e28fd4ed73dae542ab7c91f4 core-8-branch - eaf93525a5d4bd519dfd68add09a3586ca0c1831 Also, compare and contrast with the result of the following command: string is integer 18446744073709551615; # should be 0 This seems to imply that the bug involves the compiler (or lack thereof?).
- login: "mistachkin"
- mimetype: "text/plain"
- comment changed to:
Ticket change [8d105f672e] (rid 200910) by chrstphrchvz on 2022-05-21 21:29:10:
- icomment:
This behavior occurs when non-compiled <tt>StringIsCmd()</tt> is invoked (which seems to be whenever the class isn’t specified as a literal); by the time it is invoked, the value already has a bignum representation, which <tt>Tcl_GetIntFromObj()</tt> → <tt>Tcl_GetLongFromObj()</tt> extract -1 from rather than return <tt>TCL_ERROR</tt> for. So I’m inclined to think this is a bug in <tt>Tcl_GetIntFromObj()</tt> and/or <tt>Tcl_GetLongFromObj()</tt>, affecting any bignum value within [18446744069414584320,18446744073709551615], i.e. [(2**64-1)-(2**32-1),2**64-1] (at least on LP64). There should probably be a unit test made for this.
- login: "chrstphrchvz"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [3dc2b9e022] (rid 200911) by mistachkin on 2022-05-22 00:15:24:
- icomment:
Thanks for the additional research. I think there should be a series of unit tests for this. FWIW, I discovered this issue when comparing (Eagle) unit test suite results between Tcl and Eagle, i.e. Eagle produces the correct result and Tcl does not.
- login: "mistachkin"
- mimetype: "text/plain"
- icomment:
Ticket change [6bbea75da8] (rid 200950) by jan.nijtmans on 2022-05-22 17:22:53:
- assignee changed to: "jan.nijtmans"
- icomment:
Proposed fix [66a187edf25e7d07|here]. Yes, it looks like there - indeed - was a bug in Tcl_GetIntFromObj(), already exposed by testcases get-1.7 up to get-1.14. The strange thing is that Tcl_GetIntFromObj() is documented to return TCL_OK for values between -(UINT_MAX) and UINT_MAX, while Tcl_GetLongFromObj() is documented to return TCL_OK for values between -(ULONG_MAX) and ULONG_MAX. This means that Tcl_GetLongFromObj() is not usable to check whether the obj can be stored in a (long). Proposed solution: use TclGetNumberFromObj() to do the range-check first. That's what the compiled code does too ;-) Please review! Someone interested to write a bunch of unit-tests?
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Pending"
Ticket change [3cfca9d214] (rid 200951) by mistachkin on 2022-05-22 21:29:36:
- icomment:
The changes look good based on my reading; however, more eyes would be better.
- login: "mistachkin"
- mimetype: "text/plain"
- icomment:
Ticket change [972267176a] (rid 201088) by jan.nijtmans on 2022-05-25 11:06:04:
- closedate changed to: "2459724.96255279"
- closer changed to: "jan.nijtmans"
- icomment:
Fixed [e58be38bfd5ee1d4|here] Thanks for the report!
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- status changed to: "Closed"