unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Stefan Liebler via Libc-alpha <libc-alpha@sourceware.org>
To: Lukasz Majewski <lukma@denx.de>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH v2] y2038: nptl: Convert pthread_mutex_{clock|timed}lock to support 64 bit
Date: Mon, 19 Oct 2020 14:48:12 +0200	[thread overview]
Message-ID: <78fd90fb-f852-fcc2-303a-3320eff77cf6@linux.ibm.com> (raw)
In-Reply-To: <20201019135937.176650ab@jawa>

On 10/19/20 1:59 PM, Lukasz Majewski wrote:
> Hi Stefan,
> 
>> Hi Lukasz,
>>
>> With this commit, the testcase nptl/tst-robust10 times out on s390
>> (31bit, big-endian).
>>
>> For me it seems that one futex call was not adjusted while converting
>> abstime of __pthread_mutex_clocklock_common function from struct
>> timespec to struct __timespec64:
>> ┌──../nptl/pthread_mutex_timedlock.c
>> │   270                   /* Block using the futex.  */
>> │  >271                   int err = lll_futex_clock_wait_bitset
>> (&mutex->__data.__lock,
> 
> Yes. You are right. The lll_futex_clock_wait_bitset shall be converted
> as well... I must have overlooked it, sorry.
> 
>> │   272                       oldval, clockid, abstime,
>> │   273                       PTHREAD_ROBUST_MUTEX_PSHARED (mutex));
>> (gdb) where
>> #0  0x7dfb9948 in __pthread_mutex_clocklock_common
>> (mutex=mutex@entry=0x406144 <mutex>, clockid=clockid@entry=0,
>> abstime=abstime@entry=0x7ddf9290)
>>     at ../nptl/pthread_mutex_timedlock.c:271
>> #1  0x7dfb9c12 in __GI___pthread_mutex_timedlock64
>> (abstime=0x7ddf9290, mutex=0x406144 <mutex>) at
>> ../nptl/pthread_mutex_timedlock.c:632 #2  __pthread_mutex_timedlock
>> (mutex=mutex@entry=0x406144 <mutex>,
>> abstime=abstime@entry=0x7ddf930c) at
>> ../nptl/pthread_mutex_timedlock.c:644 #3  0x004020bc in thr
>> (arg=<optimized out>) at ../sysdeps/pthread/tst-robust10.c:33 #4
>> 0x7dfb6a06 in start_thread (arg=0x7ddf9b00) at pthread_create.c:463
>> #5  0x7df08434 in thread_start () at
>> ../sysdeps/unix/sysv/linux/s390/s390-32/clone.S:64
>>
>>
>> Thus the futex syscall interprets the struct __timespec64 as struct
>> timespec and the result is an infinite loop:
>> (gdb) p	abstime
>> $6 = (const struct __timespec64 *) 0x7ddf9290
>>
>> (gdb) p/x *abstime
>> $9 = {tv_sec = 0x5f8d597f, tv_nsec = 0xd79f074}
>>
>> (gdb) p/x *((struct timespec *) abstime)
>> $10 = {tv_sec = 0x0, tv_nsec = 0x5f8d597f}
>>
>> (gdb) x/4xw abstime
>> 0x7ddf9290:     0x00000000	0x5f8d597f	0x00000000
>> 0x0d79f074
>>
>>
>>
>> strace output:
>> 10:59:58.611688 futex(0x406144,
>> FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, 2148981693, {tv_sec=0,
>> tv_nsec=1603098008}, FUTEX_BITSET_MATCH_ANY) = -1 EINVAL (Invalid
>> argument) <0.000006> 10:59:58.611707 futex(0x406144,
>> FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, 2148981693, {tv_sec=0,
>> tv_nsec=1603098008}, FUTEX_BITSET_MATCH_ANY) = -1 EINVAL (Invalid
>> argument) <0.000006> 10:59:58.611724 futex(0x406144,
>> FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, 2148981693, {tv_sec=0,
>> tv_nsec=1603098008}, FUTEX_BITSET_MATCH_ANY) = -1 EINVAL (Invalid
>> argument) <0.000006>
>>
>>
>> This is also observable on x86 (32bit). But there only tv_nsec is 0
>> and thus it does not result in an infinite loop:
>> 11:22:30.348352 futex(0x804f0f4,
>> FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, 2147913074,
>> {tv_sec=1603099351, tv_nsec=0}, FUTEX_BITSET_MATCH_ANY) = -1
>> ETIMEDOUT (Connection timed out) <0.652043>
>>
>> Can you please have a look?
>>
> 
> I'm going to prepare and sent fixes ASAP. Big thanks for spotting it.
Thanks. Let me know, then I can run a test on s390 if you want.

Bye,
Stefan

  reply	other threads:[~2020-10-19 12:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-08 15:56 [PATCH v2] y2038: nptl: Convert pthread_mutex_{clock|timed}lock to support 64 bit Lukasz Majewski
2020-10-13 14:41 ` Adhemerval Zanella via Libc-alpha
2020-10-19  9:41   ` Stefan Liebler via Libc-alpha
2020-10-19 11:59     ` Lukasz Majewski
2020-10-19 12:48       ` Stefan Liebler via Libc-alpha [this message]
2020-10-19 14:59         ` Lukasz Majewski

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

  List information: https://www.gnu.org/software/libc/involved.html

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

  git send-email \
    --in-reply-to=78fd90fb-f852-fcc2-303a-3320eff77cf6@linux.ibm.com \
    --to=libc-alpha@sourceware.org \
    --cc=lukma@denx.de \
    --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).