glibc/sysdeps/nptl
Stefan Liebler be056fae3b 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 1660901840)
2018-05-17 14:05:51 +02:00
..
bits nptl: Define __PTHREAD_MUTEX_{NUSERS_AFTER_KIND,USE_UNION} 2017-11-07 11:03:01 -02:00
sys Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
aio_misc.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
allocrtsig.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fork.c nptl: Define __PTHREAD_MUTEX_{NUSERS_AFTER_KIND,USE_UNION} 2017-11-07 11:03:01 -02:00
fork.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
futex-internal.h Narrowing the visibility of libc-internal.h even further. 2017-03-01 20:33:46 -05:00
gai_misc.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
Implies
internaltypes.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
jmp-unwind.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
libc-lock.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
libc-lockP.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
librt-cancellation.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
lowlevellock-futex.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
lowlevellock.h Fix blocking pthread_join. [BZ #23137] 2018-05-17 14:05:51 +02:00
Makeconfig Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
Makefile Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
malloc-machine.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
nptl-signals.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
pthread-functions.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
pthread.h nptl: Define __PTHREAD_MUTEX_{NUSERS_AFTER_KIND,USE_UNION} 2017-11-07 11:03:01 -02:00
setxid.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
shm-directory.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
sigfillset.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
stdio-lock.h Remove _IO_MTSAFE_IO from public headers. 2017-05-11 19:14:11 -04:00
Subdirs
tcb-offsets.h
tst-mqueue8x.c
unwind-forcedunwind.c nptl: Open libgcc.so with RTLD_NOW during pthread_cancel [BZ #22636] 2018-01-15 16:06:35 +01:00