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 nptl/23137] s390: pthread_join sometimes block indefinitely (on 31bit and libc build with -Os)


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

--- Comment #3 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, release/2.27/master has been updated
       via  db988e50a87f613cb6b9e98a2fc66a4848bc3546 (commit)
      from  a06d48fb9f1837a5723ec2443d263df404d931fe (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=db988e50a87f613cb6b9e98a2fc66a4848bc3546

commit db988e50a87f613cb6b9e98a2fc66a4848bc3546
Author: Stefan Liebler <stli@linux.vnet.ibm.com>
Date:   Fri May 4 10:00:59 2018 +0200

    Fix blocking pthread_join. [BZ #23137]

    On s390 (31bit) if glibc is build with -Os, pthread_join sometimes
    blocks indefinitely. This is e.g. observable with
    testcase intl/tst-gettext6.

    pthread_join is calling lll_wait_tid(tid), which performs the futex-wait
    syscall in a loop as long as tid != 0 (thread is alive).

    On s390 (and build with -Os), tid is loaded from memory before
    comparing against zero and then the tid is loaded a second time
    in order to pass it to the futex-wait-syscall.
    If the thread exits in between, then the futex-wait-syscall is
    called with the value zero and it waits until a futex-wake occurs.
    As the thread is already exited, there won't be a futex-wake.

    In lll_wait_tid, the tid is stored to the local variable __tid,
    which is then used as argument for the futex-wait-syscall.
    But unfortunately the compiler is allowed to reload the value
    from memory.

    With this patch, the tid is loaded with atomic_load_acquire.
    Then the compiler is not allowed to reload the value for __tid from memory.

    ChangeLog:

        [BZ #23137]
        * sysdeps/nptl/lowlevellock.h (lll_wait_tid):
        Use atomic_load_acquire to load __tid.

    (cherry picked from commit 1660901840dfc9fde6c5720a32f901af6f08f00a)

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                   |    6 ++++++
 sysdeps/nptl/lowlevellock.h |   13 ++++++++-----
 2 files changed, 14 insertions(+), 5 deletions(-)

-- 
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]