GNU bug report logs - #23035
date: regression in timezone printing (+%Z)

Previous Next

Package: coreutils;

Reported by: Assaf Gordon <assafgordon <at> gmail.com>

Date: Thu, 17 Mar 2016 03:52:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 23035 in the body.
You can then email your comments to 23035 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#23035; Package coreutils. (Thu, 17 Mar 2016 03:52:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Assaf Gordon <assafgordon <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Thu, 17 Mar 2016 03:52:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Assaf Gordon <assafgordon <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: date: regression in timezone printing (+%Z)
Date: Wed, 16 Mar 2016 23:51:42 -0400
[Message part 1 (text/plain, inline)]
Hello,

I think there's a small regression in coreutils 8.25 date command with
regards to timezone printing on a machine without native 'timezone_t'.
Example:

  $ uname -a
  SunOS unstable10x 5.10 Generic_147441-19 i86pc i386 i86pc
  $ export TZ=Asia/Tokyo
  $ ./coreutils-8.24/src/date +%Z
  JST
  $ ./coreutils-8.25/src/date +%Z
  [[[empty line]]]

I suspect it has something to do with this commit:
  commit    037e3b9847feb46cf6b58d99ce960d3987faaf52
  date:     2015-07-24 01:49:31 (GMT)
  subject:  build: fprintftime/nstrftime API changes

configuration values on this machine:
    $ ggrep -E 'TZ|ZONE' lib/config.h
    #define GETTIMEOFDAY_TIMEZONE void
    #define HAVE_DECL_TZNAME 1
    #define HAVE_RUN_TZSET_TEST 1
    /* #undef HAVE_STRUCT_TM_TM_ZONE */
    /* #undef HAVE_TIMEZONE_T */
       `HAVE_STRUCT_TM_TM_ZONE' instead. */
    /* #undef HAVE_TM_ZONE */
    #define HAVE_TZNAME 1
    #define HAVE_TZSET 1
    /* #undef TZSET_CLOBBERS_LOCALTIME */

Trying to debug, I see the following:

1. in 'date.c', show_date() calls fprintftime (in ./lib/strftime.c).
The values upon entry are:

    fprintftime (s=0x8079c10 <_iob+16>, format=0x8047ccd "%Z",
tp=0xfef30200, tz=0x807b028,
        ns=446195784) at lib/strftime.c:1465
    (gdb) p *tz
    $6 = {next = 0x0, tzname_copy = {0x0, 0x0}, tz_is_set = 1 '\001',
          abbrs = 0x807b035 "Asia/Tokyo"}

2. stepping through ./lib/strftime.c:445 has this:

    445       char **tzname_vec = tzname;
    (gdb) p tzname
    $10 = {0xfef302c4 "JST", 0xfef30304 "JDT"}

3. ./lib/strftime.c:484 has this, which sets tzname_vec to nulls (from 'tz',
   originating from 'tzalloc'):

    (gdb) n
    484           tzname_vec = tz->tzname_copy;
    (gdb) n
    493       if (!(zone && *zone) && tp->tm_isdst >= 0) {
    (gdb) p tzname_vec
    $3 = (char **) 0x807b02c
    (gdb) p *tzname_vec
    $4 = 0x0
    (gdb) p zone
    $5 = 0x0
    (gdb) n
    494         zone = tzname_vec[tp->tm_isdst != 0];
    (gdb) n
    496       if (! zone)
    (gdb) p zone
    $6 = 0x0
    (gdb) n
    497         zone = "";

From this point on, 'zone' is an empty string, and that's what is printed
by 'date'.

Not sure where to start at fixing it, but I hope the attached patch can be
used to test it.

Happy to test things further if needed.
regards,
 - assaf
[Message part 2 (text/html, inline)]
[0001-tests-test-date-Z-behaviour.patch (text/x-patch, attachment)]

Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Thu, 17 Mar 2016 17:39:02 GMT) Full text and rfc822 format available.

Notification sent to Assaf Gordon <assafgordon <at> gmail.com>:
bug acknowledged by developer. (Thu, 17 Mar 2016 17:39:02 GMT) Full text and rfc822 format available.

Message #10 received at 23035-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Assaf Gordon <assafgordon <at> gmail.com>, 23035-done <at> debbugs.gnu.org
Subject: Re: bug#23035: date: regression in timezone printing (+%Z)
Date: Thu, 17 Mar 2016 10:38:06 -0700
[Message part 1 (text/plain, inline)]
On 03/16/2016 08:51 PM, Assaf Gordon wrote:
> I suspect it has something to do with this commit:
>    commit    037e3b9847feb46cf6b58d99ce960d3987faaf52

You're right, and thanks for that detailed bug report. I installed the 
attached patch, which fixed the bug for me.
[0001-date-ls-pr-fix-time-zone-abbrs-on-SysV-platforms.patch (application/x-patch, attachment)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 15 Apr 2016 11:24:03 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Pádraig Brady <P <at> draigBrady.com> to control <at> debbugs.gnu.org. (Fri, 20 Jan 2017 12:43:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-coreutils <at> gnu.org:
bug#23035; Package coreutils. (Sat, 21 Jan 2017 02:32:01 GMT) Full text and rfc822 format available.

Message #17 received at 23035 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: 23035 <at> debbugs.gnu.org, assafgordon <at> gmail.com, Paul Wise <pabs <at> debian.org>,
 851934 <at> bugs.debian.org
Subject: Re: bug#23035: date: regression in timezone printing (+%Z)
Date: Fri, 20 Jan 2017 18:31:07 -0800
[Message part 1 (text/plain, inline)]
Thanks for the heads-up. Rather than add that tzset call, which is a bit of a 
hack, I'd rather make parse_datetime2 more reentrant so that it's immune to this 
problem. So I installed this:

http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=4e6e16b3f43ce96302b1e52e48730c1f15e18c14

into Gnulib to improve the parse_datetime2 API, and installed the attached 
patches into coreutils. This uncovered a bug in one of our recently-added test 
cases, which the attached patches also fix.
[0001-build-update-gnulib-submodule-to-latest.patch (text/x-diff, attachment)]
[0002-date-fix-TZ-regression.patch (text/x-diff, attachment)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#23035; Package coreutils. (Sat, 21 Jan 2017 15:24:02 GMT) Full text and rfc822 format available.

Message #20 received at 23035 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
Cc: 23035 <at> debbugs.gnu.org
Subject: Re: bug#23035: date: regression in timezone printing (+%Z)
Date: Sat, 21 Jan 2017 15:23:05 +0000
On 21/01/17 02:31, Paul Eggert wrote:
> Thanks for the heads-up. Rather than add that tzset call, which is a bit of a 
> hack, I'd rather make parse_datetime2 more reentrant so that it's immune to this 
> problem. So I installed this:
> 
> http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=4e6e16b3f43ce96302b1e52e48730c1f15e18c14
> 
> into Gnulib to improve the parse_datetime2 API, and installed the attached 
> patches into coreutils. This uncovered a bug in one of our recently-added test 
> cases, which the attached patches also fix.

Excellent. The parse_datetime2() API is very new
and probably only used by coreutils, so there
should be no other fallout from improving the API.

I've pushed this NEWS item for the fix.

+  date again converts from a specified time zone.  Previously output was
+  not converted to the local time zone, and remained in the specified one.
+  [bug introduced in coreutils-8.26]

thanks!
Pádraig.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 19 Feb 2017 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 66 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.