public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Stefan Liebler <stli@linux.ibm.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH v2] Use LFS and 64 bit time for installed programs (BZ #15333)
Date: Wed, 12 Jan 2022 11:44:55 -0300	[thread overview]
Message-ID: <8699437a-bb09-9b62-0302-10434d4aa18f@linaro.org> (raw)
In-Reply-To: <f4a7d00d-4a36-534b-21be-bb121069d658@linux.ibm.com>



On 12/01/2022 11:13, Stefan Liebler wrote:
> On 14/12/2021 20:35, DJ Delorie via Libc-alpha wrote:
> ...
>>
>> LGTM
>> Reviewed-by: DJ Delorie <dj@redhat.com>
>>
> 
> Starting with this commit a6d2f948b71adcb5ea395cb04833bc645eab45e6, I
> get a test fail on s390:
> FAIL: resolv/tst-p_secstodate
> 
> Test 0: 0 -> 19700101000000
> Test 1: 12345 -> 19700101000000
> test 1 failedTest 2: 999999999 -> 19700101000000
> test 2 failedTest 3: 2147483647 -> 19700101000000
> test 3 failedTest 4: 2147483648 -> <overflow>
> Test 5: 4294967295 -> <overflow>
> 
> It turns out that there is a type-mismatch of time_t on caller and
> callee side.
> 
> in libresolv.so: resolv/res_debug.c: __p_secstodate(u_long secs)
> time_t clock = secs;
> struct tm *time = __gmtime_r(&clock, &timebuf);
> 
> (gdb) p &clock
> $1 = (time_t *) 0x7ffff1c8
> (gdb) ptype time_t
> type = long long
> (gdb) p	sizeof(time_t)
> $2 = 8
> (gdb) x/2xw 0x7ffff1c8
> 0x7ffff1c8:     0x00000000	0x7fffffff
> 
> The secs are stored as 8byte long long on stack and the pointer is
> passed to __gmtime_r in libc.so:
> time/gmtime.c:
> /* Provide a 32-bit variant if needed.  */
> #if __TIMESIZE != 64
> struct tm *
> __gmtime_r (const time_t *t, struct tm *tp)
> {
>   __time64_t t64 = *t;
>   return __gmtime64_r (&t64, tp);
> }
> #endif
> 
> (gdb) ptype time_t
> type = long
> (gdb) p	sizeof(time_t)
> $3 = 4
> (gdb) p         *t
> $4 = 0
> (gdb) ptype __time64_t
> type = long long
> 
> On libc.so side, time_t is defined as 4byte long, thus the value of t is
> read as 0x0 instead of 0x7fffffff.
> 
> resolv/res_debug.c is built with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
> and time/gmtime.c is built without those defines.
> 
> 
> @Adhemerval:
> Can you please have a look?


libresolv should not be built with the time64 flags, the above patch should fix
it.

diff --git a/Makeconfig b/Makeconfig
index 06f1cca320..9b6fc6b08f 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -867,7 +867,7 @@ endif
 +extra-math-flags = $(if $(filter libm,$(in-module)),-fno-math-errno,-fmath-errno)
 
 # Use 64 bit time_t support for installed programs
-installed-modules = nonlib nscd lddlibc4 libresolv ldconfig locale_programs \
+installed-modules = nonlib nscd lddlibc4 ldconfig locale_programs \
                    iconvprogs libnss_files libnss_compat libnss_db libnss_hesiod \
                    libutil libpcprofile libSegFault
 +extra-time-flags = $(if $(filter $(installed-modules),\

I have this issue on my backlog since I saw it on powerpc32.  I will check on
i686 and powerpc and install it.

  reply	other threads:[~2022-01-12 14:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-22 17:27 Adhemerval Zanella
2021-12-14 19:35 ` DJ Delorie
2022-01-12 14:13   ` Stefan Liebler
2022-01-12 14:44     ` Adhemerval Zanella [this message]
2022-01-12 16:07       ` Stefan Liebler
2021-12-28 20:37 ` Florian Weimer
2021-12-29 11:59   ` Adhemerval Zanella
2021-12-29 12:35     ` Florian Weimer
2021-12-29 13:08       ` Adhemerval Zanella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8699437a-bb09-9b62-0302-10434d4aa18f@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    --cc=stli@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).