bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 6/7] nstrftime, time_rz: don’t depend on tzname


From: Bruno Haible
Subject: Re: [PATCH 6/7] nstrftime, time_rz: don’t depend on tzname
Date: Tue, 18 Jun 2024 15:02:28 +0200

Paul Eggert wrote:
> > After the Solaris crash fix, the nstrftime tests still fail, due to this
> > output:
> > 
> > <-00>0: expected "1970-01-01 00:00:00 -0000 (-00)", got "1970-01-01 
> > 00:00:00 +0000 (-00)"
> > <-00>0: expected "1985-11-05 00:53:21 -0000 (-00)", got "1985-11-05 
> > 00:53:21 +0000 (-00)"
> > <-00>0: expected "2001-09-09 01:46:42 -0000 (-00)", got "2001-09-09 
> > 01:46:42 +0000 (-00)"
> ...
> I installed the attached to try to fix that issue. Thanks for reporting it.

Thanks. I confirm it fixes the test failure on Solaris 11.4.

But there are two problems:

1) On FreeBSD 5.2.1 and OpenBSD 6.0, I see a compiler warning:

gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I../../gllib -I..  
-DGNULIB_STRICT_CHECKING=1 -I/home/bruno/include -I/usr/local/include -Wall 
-D_THREAD_SAFE  -g -O2 -MT c-nstrftime.o -MD -MP -MF .deps/c-nstrftime.Tpo -c 
-o c-nstrftime.o ../../gllib/c-nstrftime.c
In file included from ../../gllib/c-nstrftime.c:20:
../../gllib/strftime.c: In function `__strftime_internal':
../../gllib/strftime.c:1471: warning: label `underlying_strftime' defined but 
not used

Also, there is an inconsistency: In underlying_strftime, the condition is
  # if USE_C_LOCALE && (HAVE_STRFTIME_L || HAVE_STRFTIME_LZ)
whereas the rest of the code has
  # if USE_C_LOCALE && HAVE_STRFTIME_L
and also a dozen of
  # if USE_C_LOCALE && !HAVE_STRFTIME_L

Fixed through the first patch below.

2) On NetBSD, one out of 4 unit tests fails:

PASS: test-c-nstrftime-1.sh
PASS: test-c-nstrftime-2.sh
PASS: test-nstrftime-1.sh
FAIL: test-nstrftime-2.sh

The cause is a crash:
main
  -> locales_test
       -> FUNC_CHECKED
            -> nstrftime
                 -> __strftime_internal
                      -> underlying_strftime
                           -> strftime_lz
                                -> _fmt
                                     -> _fmt
                                          -> __tzgetname50

tzgetname = __tzgetname50 assumes that its first argument is != NULL.

strftime_lz and _fmt pass their timezone_t argument down.

The crashing call is
  underlying_strftime (tz=NULL, ubuf, ubufsize=1024, modifier=0, 
format_char='c', tp)

tz=NULL means universal time (a.k.a. GMT) in our strftime.h, but is undefined
behaviour for NetBSD's functions. See https://man.netbsd.org/tzset.3 .

Fixed through the second patch below.

Bruno

Attachment: 0001-c-nstrftime-Fix-warning-on-platforms-without-strftim.patch
Description: Text Data

Attachment: 0002-nstrftime-Fix-crash-on-NetBSD-10.0.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]