This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug time/19253] New: tzset() ineffective when temporary TZ did not include DST rules


https://sourceware.org/bugzilla/show_bug.cgi?id=19253

            Bug ID: 19253
           Summary: tzset() ineffective when temporary TZ did not include
                    DST rules
           Product: glibc
           Version: 2.22
            Status: NEW
          Severity: normal
          Priority: P2
         Component: time
          Assignee: unassigned at sourceware dot org
          Reporter: vadmium+floss at gmail dot com
  Target Milestone: ---

Created attachment 8788
  --> https://sourceware.org/bugzilla/attachment.cgi?id=8788&action=edit
Demo program

Some parts of the test suite of the Python programming language temporarily
change the time zone by calling tzset() after setting the TZ environment
variable. Then they change TZ back to the original value, or unset it, as
appropriate, and call tzset() to restore the usual time zone. This strategy
fails to restore the original time zone, at least when both the following are
true:

* The normal time zone is set to America/New_York. On the other hand, having
UTC as the normal time zone does not trigger the problem.
* The temporary TZ value did not include DST rules. The best workaround seems
to be to always include DST rules with the TZ value.

See <https://bugs.python.org/issue20220> for more info. The failure was
originally seen on two System Z buildbots: GNU/Linux s390x System Z SLES 12,
and GNU/Linux s390x System Z RHEL 7.1. I have also reproduced this on my Arch
Linux x86-64 computer.

Here is a demonstration using the attached tz-quirk.c program. You have to give
it the temporary TZ value as argv[1].

$ gcc -Wall tz-quirk.c -o tz-quirk
$ sudo timedatectl set-timezone America/New_York
$ ./tz-quirk "STD-1DST"  # Optional DST rules omitted
Initially: TZ=<unset> tzname={"GMT", "GMT"}
After tzset(): TZ=<unset> tzname={"EST", "EDT"}
Set TZ: TZ="STD-1DST" tzname={"STD", "DST"}
Unset TZ: TZ=<unset> tzname={"STD", "DST"}  <== Not restored!
$ ./tz-quirk "STD-1DST,M3.2.0,M11.1.0"  <== DST rules included
Initially: TZ=<unset> tzname={"GMT", "GMT"}
After tzset(): TZ=<unset> tzname={"EST", "EDT"}
Set TZ: TZ="STD-1DST,M3.2.0,M11.1.0" tzname={"STD", "DST"}
Unset TZ: TZ=<unset> tzname={"EST", "EDT"}  <== Restored as expected
$ pacman -Qo /lib/libc.so.6  # Arch Linux
/usr/lib/libc.so.6 is owned by glibc 2.22-3

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]