|
2024-08-22
| ||
| 13:44 | Merge [862eaba11a22af37], "Fix testcase for [00655c867e] (making it independent from timezone)", "Fi... check-in: 67b8c1207f user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE | |
|
2024-08-20
| ||
| 20:14 | Merge [5b82f60b5df259fc]: Fix [00655c867e]: ClockGetdatefieldsObjCmd(): avoid signed integer overfl... check-in: 56f804fdc4 user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE | |
|
2023-09-21
| ||
| 11:15 | • Closed ticket [00655c867e]: ClockGetdatefieldsObjCmd(): avoid signed integer ove... artifact: 352b13db5d user: jan.nijtmans | |
| 11:10 | Fix testcase for [00655c867e] (making it independent from timezone) check-in: 6f0d308463 user: jan.nijtmans tags: core-8-6-branch | |
|
2023-09-20
| ||
| 22:02 | • Ticket [00655c867e] ClockGetdatefieldsObjCmd(): avoid signed integer overflow an... artifact: 989d74d3c0 user: chrstphrchvz | |
| 21:59 | • Add attachment clock-7.10-add-utc.diff to ticket [00655c867eabd57a|0065... artifact: a21a4f2486 user: chrstphrchvz | |
| 20:50 | • Ticket [00655c867e] ClockGetdatefieldsObjCmd(): avoid signed integer overflow an... artifact: 021b0ac236 user: chrstphrchvz | |
| 20:09 | • Ticket [00655c867e]: 3 changes artifact: b0422cc405 user: chrstphrchvz | |
| 16:57 | • Ticket [00655c867e]: 3 changes artifact: 3503ed3959 user: chrstphrchvz | |
| 15:54 | • Ticket [00655c867e]: 3 changes artifact: 08ac420864 user: jan.nijtmans | |
| 15:12 | • Ticket [00655c867e]: 3 changes artifact: 2f4268f4a2 user: chrstphrchvz | |
| 13:37 | • Pending ticket [00655c867e]. artifact: 45f0f2a9ec user: jan.nijtmans | |
|
2023-09-14
| ||
| 21:19 | • Closed ticket [00655c867e]. artifact: 9823740c38 user: jan.nijtmans | |
| 21:17 | Fix [00655c867e]: ClockGetdatefieldsObjCmd(): avoid signed integer overflow and platform-dependent b... check-in: ee677ecc84 user: jan.nijtmans tags: core-8-6-branch | |
| 08:43 | • Closed ticket [b9a41897a8]: ClockGetdatefieldsObjCmd(): signed integer overflow<... artifact: 69b8675655 user: chrstphrchvz | |
|
2023-05-09
| ||
| 21:16 | • Add attachment 00655c867eab.diff to ticket [00655c867eabd57a|00655c867e... artifact: e83aa4bc3e user: chrstphrchvz | |
| 21:05 | • New ticket [00655c867e] ClockGetdatefieldsObjCmd(): avoid signed integer overflo... artifact: 129332b760 user: chrstphrchvz | |
ClockGetdatefieldsObjCmd(): avoid signed integer overflow and platform-dependent behavior
generic/tclClock.c:472:52: runtime error: signed integer overflow: 9223372036854775807 + 210866803200 cannot be represented in type 'long long'
See attached patch. To avoid the overflow, I suggest dividing by SECONDS_PER_DAY first and then adding JULIAN_DAY_POSIX_EPOCH instead. The quotient also needs to be consistently rounded down, rather truncated towards 0 (GNU C and C99) or however a particular platform chooses (C89); otherwise incorrect results are produced for time values prior to the POSIX epoch. Not rounding down already produces incorrect results for time values prior to Julian day 0; the proposed clock-7.10 test currently fails with
-210866803200 -210866889600 -1 -210866803201 0 -210866803200 0 0 0when integer division truncates toward 0.
67b8c1207fMerge [862eaba11a22af37], "Fix testcase for [00655c867e] (making it independent from timezone)", "Fix [47902ec47a]: ThreadSafeLocalTime(): remove redundant localtime() call", and "Fix [e368ba6683]: ThreadSafeLocalTime(): check if localtime_r() encountered error". check-in2024-08-22 13:44:0456f804fdc4Merge [5b82f60b5df259fc]: Fix [00655c867e]: ClockGetdatefieldsObjCmd(): avoid signed integer overflow and platform-dependent behavior. check-in2024-08-20 20:14:516f0d308463Fix testcase for [00655c867e] (making it independent from timezone) check-in2023-09-21 11:10:34ee677ecc84Fix [00655c867e]: ClockGetdatefieldsObjCmd(): avoid signed integer overflow and platform-dependent behavior check-in2023-09-14 21:17:2169b8675655Closed ticket [b9a41897a8]: ClockGetdatefieldsObjCmd(): signed integer overflow plus 6 other changes ticket2023-09-14 08:43:06
Fixed [here].
Many thanks!
The new testcase fails in a OPTS=static,msvcrt build in Visual Studio, passes in all other configurations.
clock.test==== clock-7.10 Julian Day, negative amount FAILED ==== Contents of test case:
# Note: %J does not accept negative input; # add negative amounts to Julian day 0 instead set s0 [clock scan 0 -format %J -gmt true] set J0 [scan [clock format $s0 -format %J -gmt true] %lld] set s0m1d [clock add $s0 -1 days] set s0m24h [clock add $s0 -24 hours] set J0m24h [scan [clock format $s0m24h -format %J -gmt true] %lld] set s0m1s [clock add $s0 -1 seconds] set J0m1s [scan [clock format $s0m1s -format %J -gmt true] %lld] list $s0m1d $s0m24h $J0m24h $s0m1s $J0m1s $s0 $J0 [::tcl::mathop::== $s0m1d $s0m24h] [::tcl::mathop::== $J0m24h $J0m1s]---- Test generated error; Return code was: 1 ---- Return code should have been one of: 0 2 ---- errorInfo: localtime failed (clock value may be too large/small to represent) while executing "return -options $opts $result" (procedure "::tcl::clock::add" line 98) invoked from within "clock add $s0 -1 days" ("uplevel" body line 6) invoked from within "uplevel 1 $script" ---- errorCode: CLOCK localtimeFailed ==== clock-7.10 FAILED
cmdAH.test
I have reproduced this locally and will take a look. Note that without the change to tclClock.c the test still fails for the same reason.
Strange also, that all tests in 8.7 pass. Why does this fail in 8.6?
I notice that ::tcl::clock::GetSystemTimeZone is returning :localtime when running tests for the OPTS=static,mscvrt configuration (rather than e.g. :America/Chicago), which causes ConvertUTCToLocal() to use ConvertUTCToLocalUsingC() instead of ConvertUTCToLocalUsingTable(). I am guessing this is not intentional.
However I wonder if clock-7.10 should still work with :localtime, or be constrained to not run under :localtime. Either way, having a similar test which forces :localtime could be useful.
However, the conditions under which localtime()/localtime_r() encounters errors (e.g. EOVERFLOW) are platform-dependent. So a test which uses these functions may not be portable.
The exact cutoffs for localtime()/localtime_r() errors may depend on the platform epoch, but if struct tm is consistently defined, then I would think time values with years way outside of [1900+INT_MIN,1900+INT_MAX] will reliably cause an error. I will likely open other tickets about this.
I neglected how clock add … days takes -timezone into consideration. Specifying -timezone :UTC to clock add … days avoids the failure on OPTS=static,msvcrt, although whether GetSystemTimeZone is correct or unexpectedly :localtime is beyond the scope of this test. -timezone should likely also be specified in the test’s other clock add usage for consistency. See attached patch.
Thanks! Closing now.
Attachments:
- clock-7.10-add-utc.diff [download] added by chrstphrchvz on 2023-09-20 21:59:44. [details]
- 00655c867eab.diff [download] added by chrstphrchvz on 2023-05-09 21:16:27. [details]