|
2026-09-11
| ||
| 07:24 | • Ticket [832d098fdf] Clock reads TZif version 3 and 4 zoneinfo files as version 1... artifact: d7271aca3e user: oehhar | |
|
2026-09-10
| ||
| 20:53 | • Closed ticket [832d098fdf]. artifact: 6434f6caa1 user: sebres | |
| 20:48 | merge bug-832d098fdf-8.6, fixes [832d098fdfec8f00]: zoneinfo reader - accept any TZif version 2+; te... check-in: 4bc3ef2e6e user: sebres tags: core-9-0-branch | |
| 20:35 | merge bug-832d098fdf-8.6, fixes [832d098fdfec8f00]: zoneinfo reader - accept any TZif version 2+ (RF... check-in: 9bd0b6dfe1 user: sebres tags: core-8-6-branch | |
|
2026-09-08
| ||
| 09:12 | • Ticket [832d098fdf] Clock reads TZif version 3 and 4 zoneinfo files as version 1... artifact: 0c2a26fbae user: oehhar | |
| 05:57 | • Ticket [832d098fdf]: 3 changes artifact: 229e13b0c6 user: kenneth.kienle | |
|
2026-09-07
| ||
| 22:38 | fixes [832d098fdfec8f00]: zoneinfo reader - accept any TZif version from 2 up, not version 2 only (R... closed check-in: a9b3769509 user: kenneth.kienle tags: bug-832d098fdf-8.6 | |
|
2026-09-03
| ||
| 19:55 | • New ticket [7bad415e3e] Free-form clock scan reads "+02" as two minute... artifact: 2b3b630918 user: kenneth.kienle | |
| 19:47 | • Add attachment clock-tzif-versions-2-and-up.patch to ticket [832d098fdf... artifact: e6aaaab439 user: kenneth.kienle | |
| 19:47 | • Add attachment tcl-tz-repro.tcl to ticket [832d098fdf] artifact: 5c6ddf5a06 user: kenneth.kienle | |
| 19:46 | • New ticket [832d098fdf] Clock reads TZif version 3 and 4 zoneinfo files as versi... artifact: b0347cdfb9 user: kenneth.kienle | |
Clock reads TZif version 3 and 4 zoneinfo files as version 1 - zones with an extended footer lose all their transitions
library/clock.tcl's ReadZoneinfoFile selects the 64-bit data block and the
TZ-string footer only when the header's version byte is exactly "2"
(two sites). RFC 9636 (which obsoletes RFC 8536) defines versions '2',
'3' and '4', each conforming to the one before (section 3.1), and says
of readers in section 4: "When reading a version 2 or higher file, readers
SHOULD ignore the version 1 header and data block except for the purpose of
skipping over them."
zic writes version 3 whenever a zone's footer needs the TZ-string
extension of section 3.3.2 (a transition hour outside 0..24), and version 4
for leap-second tables with a truncation or expiry. In tzdata 2026c, 12 of
598 zones are version 3: Israel, Asia/Jerusalem, Asia/Tel_Aviv
(M3.4.4/26), Asia/Gaza, Asia/Hebron (/50), America/Santiago,
Chile/Continental, Chile/EasterIsland, Pacific/Easter, America/Nuuk,
America/Godthab, America/Scoresbysund (M3.5.0/-1).
For those files Tcl parses the 32-bit block. With zic's default -b slim
output that block is empty, so the zone loads as a single entry, LMT
forever; with -b fat data the 32-bit transitions are read and the footer
is lost, so the bug shows after 2037. Anything reading the system zoneinfo
(--with-tzdata=no, or a zone not in Tcl's own tzdata) is affected.
% clock format 0 -timezone :UTC ;# load the ensemble
% ::tcl::clock::LoadZoneinfoFile Asia/Jerusalem
% llength $::tcl::clock::TZData(:Asia/Jerusalem)
1
% ::tcl::clock::LoadZoneinfoFile Asia/Kolkata ;# a version-2 file
% llength $::tcl::clock::TZData(:Asia/Kolkata)
8
Reproduction without tzdata: the attached tcl-tz-repro.tcl writes
synthetic TZif files into a scratch zoneinfo directory in the shape of
clock-56.1/clock-56.2 (a version-2 control, version 3 with footer
<-02>2<-01>,M3.5.0/-1,M10.5.0/0, version 3 with IST-2IDT,M3.4.4/26,M10.5.0,
a version-4 header), prepends it to ::tcl::clock::ZoneinfoPaths, and
formats 2030-01-11 and 2030-07-11 12:00 UTC through each. Stock 8.6.18
and 9.0.4 return standard time for summer in all three non-control zones
(-02 for -01, IST for IDT). The script also covers two other clock
bugs (separate tickets); the reader checks are the first block.
Fix (attached clock-tzif-versions-2-and-up.patch, 8 lines against
core-8-6-branch; applies to main at other offsets):
- Both version checks read the 64-bit block and the footer for any
version from 2 up -
[string is digit -strict $version] && $version >= 2— the RFC's "2 or higher", and what glibc does (any nonzero version byte). ParsePosixTimeZone's two transition-time hour fields (groups 16 and 24) become/ ( [-+]?[[:digit:]]{1,3} )for section 3.3.2's range of -167..167.ProcessPosixTimeZonealready scans the field with%dand adds seconds, so a negative hour needs no other change; hour 26 already fit the old pattern.
Verification: the script's reader checks pass. On real data, all 12
version-3 zones and 10 version-2 controls were compared with glibc's
date on the same installed files at 6,256 instants (30-day steps
2026–2045, hourly across the Greenland and Israel 2026 and 2031 transition
weekends): 0 mismatches. tests/clock.test is unchanged by the fix.
Proposed tests: clock-56.4 (version 3, negative transition hour),
clock-56.5 (version 3, hour 26), clock-56.6 (version 4 header). The
script's tzif procedure builds each file in a dozen lines.
2b3b630918New ticket [7bad415e3e] Free-form clock scan reads "+02" as two minutes in 8.6 (backport of [51aa53616067cb63] without semantic predicates); the 9.x fix misreads a zone followed by a number. ticket2026-09-03 19:55:01
There is a branch for this on bug-832d098fdf-8.6, off core-8-6-branch.
How this came up, since it explains the odd configuration: I build and test Tcl 8.6 against the system's tzdata rather than the bundled copy. That surfaced this issue, and a default build does not show it.
The reader used the 64-bit block and the footer only when the version byte was exactly "2". RFC 9636 section 3.1 defines '2', '3' and '4' as each conforming to the one before, and section 4 says a reader should use the version 1 block only to skip over it. With tzdata 2026c, 12 of 598 zones are version 3:
zic -b slim -d zi africa antarctica asia australasia europe \
northamerica southamerica etcetera backward factory
for f in $(find zi -type f); do
[ "$(head -c5 $f | tail -c1)" = 3 ] && echo $f
done
Asia/Jerusalem, Asia/Tel_Aviv, Israel, Asia/Gaza, Asia/Hebron, America/Santiago, Chile/Continental, Chile/EasterIsland, Pacific/Easter, America/Godthab, America/Nuuk, America/Scoresbysund
When this is reachable matters. SetupTimeZone reads the bundled tzdata first, so a default build is not affected. It affects builds made with --with- tzdata=no, zones that are not in the bundled copy, and TZif files read directly.
Stock 8.6, no bundled tzdata, reading the real slim Asia/Jerusalem:
@1700000000 -> '+0000 ' (UTC, empty abbreviation)
patched -> '+0200 IST' (glibc agrees)
With fat data the reader falls back to the 32-bit block instead, which cannot hold a transition after 2038 and has no footer:
America/Nuuk 2040-07-01 stock -0200 patched -0100 glibc -0100
Asia/Gaza 2050-07-29 stock +0200 patched +0300 glibc +0300
The scope is all 598 zones from a slim build, at 12 instants from 1938 to 2084, through stock and patched: 144 of 7176 results differ, all of them inside those 12 zones. No other zone changes at any instant. On all 144, patched agrees with glibc and stock does not.
Two further changes go with the footers that version 3 exists for. The transition hour now takes an optional sign and up to three digits, which covers the section 3.3.2 range of -167 to 167 (the pattern is a superset of it; no bound is enforced). Of the 598 zones in a slim 2026c build, three write a signed hour - America/Godthab, America/Nuuk and America/Scoresbysund, all /-1. None write a three-digit hour, so the sign is needed by data that exists today and the width is forward compatibility. And the sign applies to the whole time of day, not to the hours field alone, because [::scan -0 %d] returns 0 and loses it.
The version test is [string is digit -strict $version] && $version >= 2. The -strict guard is not about version 1: a version 1 file has NUL in that byte, and both NUL and ASCII '1' already fail a bare >= 2. What it stops is any non- digit byte from 0x3a up, which Tcl's string comparison would otherwise accept
- 198 byte values.
Accepting version 4 is forward compatibility only. ReadZoneinfoFile refuses a file whose version 1 header declares leap seconds, and a zic-written version 4 file has them, so in the fat case such a file does not reach the new branch.
Tests clock-56.5 to 56.11 use synthetic TZif files and need neither system nor bundled tzdata. Reverting one mechanism at a time, measured:
version check (either site) fails 56.5, 56.6, 56.7
signed / three-digit hour pattern fails 56.8, 56.9, 56.10, 56.11
sign applied to the whole time of day fails 56.10, 56.11
sign taken from [::scan], not the text fails 56.11
No test separates the two version-check sites from each other; reverting either one fails the same three.
56.9 is deliberately absent from the third row. Its footer is M3.5.0/-1, with
no minutes and no seconds, so sign * (h * 3600) and (sign * h) * 3600 are
the same number and the fixture cannot see which one the code computes. It is
coverage for the hour pattern, which is the row it does appear in. I mention
it because a reader who reverts by dropping the sign factor, rather than by
restoring the old placement, will see 56.9 fail and conclude the table is
wrong.
If you check the fixtures with another tool they contain no transitions, and
glibc ignores a footer in that case, so TZ=:<file> date will disagree. RFC
9636 section 3.2 says the footer governs when there are no transitions. The
expected values were computed with glibc from each footer's TZ string instead.
One issue I found next to this and did not touch (it is separate and already
reachable without this change) is that the leap-second refusal above reads the
VERSION 1 header, and zic -b slim writes that block empty, so a slim file with
leap seconds passes the guard. The footer seek then uses 8 * $nLeap, but
leap records in the 64-bit block are 12 bytes, so the footer is read from the
wrong offset. Measured on a zic -b slim -L leapseconds build of 2026c:
Europe/Berlin (version 2, 27 leap records)
stock 8.6 today -> error, "unable to parse time zone specification"
This is not caused by this branch, but this branch does make it reachable for the 12 version 3 zones, which go from silently wrong to that same error:
Asia/Jerusalem stock '+0000 ' -> patched: the parse error
America/Nuuk stock '+0000 ' -> patched: the parse error
Changing 8 * $nLeap to 12 * $nLeap makes all three correct and agree with
glibc on offset and abbreviation. I have kept it out of this branch to keep
things in scope. I'm happy to file it separately or to add it here, I just
didn't want it to be a surprise.
This is still open on trunk: library/clock.tcl there has the same $version eq "2" test and the same two-digit hour pattern.
Kenneth
Great, thanks. Sergey (or others), may you double check the branch and merge if ok?
Thanks for all, Harald
Merged to 8.6 and 9.0 ([4bc3ef2e6ea2e4b7]), with a pinch of simplification/deduplication for tests.
Thx!
Thanks Kenneth and Sergey for the great cooperation and result! We really appreciate! Harald