about summary refs log tree commit diff
path: root/elf/tst-dl_find_object-threads.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2022-01-07 13:21:57 +0100
committerFlorian Weimer <fweimer@redhat.com>2022-01-07 13:21:57 +0100
commitacbaad31e8ea10fce8b9c0aef58afb388bf7489d (patch)
treeeb8a5902a2080aa094a823ef02a64f78c2da4d71 /elf/tst-dl_find_object-threads.c
parentd5b0046e3ddf8ea82a3eff74068b8fd2665b98db (diff)
downloadglibc-acbaad31e8ea10fce8b9c0aef58afb388bf7489d.tar.gz
glibc-acbaad31e8ea10fce8b9c0aef58afb388bf7489d.tar.xz
glibc-acbaad31e8ea10fce8b9c0aef58afb388bf7489d.zip
elf: Fix fences in _dl_find_object_update (bug 28745)
As explained in Hans Boehm, Can Seqlocks Get Along with Programming
Language Memory Models?, an acquire fence is needed in
_dlfo_read_success.  The lack of a fence resulted in an observable
bug on powerpc64le compile-time load reordering.

The fence in _dlfo_mappings_begin_update has been reordered, turning
the fence/store sequence into a release MO store equivalent.

Relaxed MO loads are used on the reader side, and relaxed MO stores
on the writer side for the shared data, to avoid formal data races.
This is just to be conservative; it should not actually be necessary
given how the data is used.

This commit also fixes the test run time.  The intent was to run it
for 3 seconds, but 0.3 seconds was enough to uncover the bug very
occasionally (while 3 seconds did not reliably show the bug on every
test run).

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
Diffstat (limited to 'elf/tst-dl_find_object-threads.c')
-rw-r--r--elf/tst-dl_find_object-threads.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/elf/tst-dl_find_object-threads.c b/elf/tst-dl_find_object-threads.c
index de3b468fb8..331b90f6ec 100644
--- a/elf/tst-dl_find_object-threads.c
+++ b/elf/tst-dl_find_object-threads.c
@@ -138,12 +138,12 @@ check (void *address, struct dl_find_object *expected, int line)
 #endif
 }
 
-/* Request process termination after 3 seconds.  */
+/* Request process termination after 0.3 seconds.  */
 static bool exit_requested;
 static void *
 exit_thread (void *ignored)
 {
-  usleep (3 * 100 * 1000);
+  usleep (300 * 1000);
   __atomic_store_n (&exit_requested, true,  __ATOMIC_RELAXED);
   return NULL;
 }