|
2022-05-25
| ||
| 12:55 | Simplify solution for [76ad7aeba3]: No need to call TclGetNumberFromObj() twice, since it's already ... check-in: f518cb272e user: jan.nijtmans tags: core-8-6-branch | |
| 11:06 | • Closed ticket [76ad7aeba3]: boundary case bug in string is integer plus 5 ... artifact: 972267176a user: jan.nijtmans | |
| 10:28 | Fix [76ad7aeba3]: boundary case bug in [string is integer] check-in: e58be38bfd user: jan.nijtmans tags: core-8-6-branch | |
|
2022-05-22
| ||
| 21:29 | • Ticket [76ad7aeba3] boundary case bug in string is integer status still Pe... artifact: 3cfca9d214 user: mistachkin | |
| 17:22 | • Pending ticket [76ad7aeba3]. artifact: 6bbea75da8 user: jan.nijtmans | |
| 17:11 | Proposed fix for [76ad7aeba3]: boundary case bug in [string is integer]. Missing: more unit-tests check-in: 66a187edf2 user: jan.nijtmans tags: bug-76ad7aeba3 | |
| 00:15 | • Ticket [76ad7aeba3] boundary case bug in string is integer status still Op... artifact: 3dc2b9e022 user: mistachkin | |
|
2022-05-21
| ||
| 21:29 | • Ticket [76ad7aeba3]: 3 changes artifact: 8d105f672e user: chrstphrchvz | |
|
2022-05-20
| ||
| 17:43 | • Ticket [76ad7aeba3]: 3 changes artifact: 5de8b3151b user: mistachkin | |
| 17:42 | • Ticket [76ad7aeba3]: 3 changes artifact: 289eb5dc85 user: mistachkin | |
| 17:32 | • New ticket [76ad7aeba3]. artifact: a93ee0f462 user: mistachkin | |
boundary case bug in [string is integer]
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?).
f518cb272eSimplify solution for [76ad7aeba3]: No need to call TclGetNumberFromObj() twice, since it's already done inside TclGetIntFromObj() check-in2022-05-25 12:55:23e58be38bfdFix [76ad7aeba3]: boundary case bug in [string is integer] check-in2022-05-25 10:28:5266a187edf2Proposed fix for [76ad7aeba3]: boundary case bug in [string is integer]. Missing: more unit-tests check-in2022-05-22 17:11:58
This behavior occurs when non-compiled StringIsCmd() 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 Tcl_GetIntFromObj() → Tcl_GetLongFromObj() extract -1 from rather than return TCL_ERROR for.
So I’m inclined to think this is a bug in Tcl_GetIntFromObj() and/or Tcl_GetLongFromObj(), 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.
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.
Proposed fix [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?
The changes look good based on my reading; however, more eyes would be better.
Fixed [here]
Thanks for the report!