Skip to content
Tcl Source Code History Of Ticket 832d098fdfec8f00
Login

History Of Ticket 832d098fdfec8f00

Artifacts Associated With Ticket 832d098fdfec8f00

  1. Ticket change [b0347cdfb9] (rid 255925) by kenneth.kienle on 2026-09-03 19:46:50:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-markdown"
    4. comment initialized to:
      `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):
      
      1. 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).
      2. `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. `ProcessPosixTimeZone` already scans the field with `%d` and
         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.
      
    5. foundin initialized to: "8.6.18, 9.0.4"
    6. is_private initialized to: "0"
    7. login: "kenneth.kienle"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "39c7f150e83208e701f26c9bf329dc8b2f4bc4d1"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "kenneth.kienle"
    14. subsystem initialized to: "06. Time Measurement"
    15. title initialized to:
      Clock reads TZif version 3 and 4 zoneinfo files as version 1 - zones with an extended footer lose all their transitions
      
    16. type initialized to: "Bug"
  2. Add attachment "clock-tzif-versions-2-and-up.patch" [e6aaaab439] (rid 255926) by kenneth.kienle on 2026-09-03 19:47:51.

  3. Add attachment "tcl-tz-repro.tcl" [5c6ddf5a06] (rid 255927) by kenneth.kienle on 2026-09-03 19:47:51.

  4. Ticket change [229e13b0c6] (rid 256134) by kenneth.kienle on 2026-09-08 05:57:17:

    1. icomment:
      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
      
    2. login: "kenneth.kienle"
    3. mimetype: "text/x-markdown"
  5. Ticket change [0c2a26fbae] (rid 256138) by oehhar on 2026-09-08 09:12:12:

    1. icomment:
      Great, thanks.
      Sergey (or others), may you double check the branch and merge if ok?
      
      Thanks for all,
      Harald
      
    2. login: "oehhar"
    3. mimetype: "text/x-fossil-wiki"
    4. username: "oehhar"
  6. Ticket change [6434f6caa1] (rid 256157) by sebres on 2026-09-10 20:53:35:

    1. closedate changed to: "2461294.370549479"
    2. closer changed to: "sebres"
    3. foundin changed to: "8.6+"
    4. icomment:
      Merged to 8.6 and 9.0 ([4bc3ef2e6ea2e4b7]), with a pinch of simplification/deduplication for tests.
      
      Thx!
      
    5. login: "sebres"
    6. mimetype: "text/x-fossil-wiki"
    7. resolution changed to: "Fixed"
    8. status changed to: "Closed"
  7. Ticket change [d7271aca3e] (rid 256204) by oehhar on 2026-09-11 07:24:37:

    1. closedate changed to: "2461294.808768854"
    2. closer changed to: "oehhar"
    3. icomment:
      Thanks Kenneth and Sergey for the great cooperation and result!
      We really appreciate!
      
      Harald
      
    4. login: "oehhar"
    5. mimetype: "text/plain"
    6. username: "oehhar"