public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-5330] libstdc++: Fix handling of futex wake [PR 97936]
@ 2020-11-25 10:33 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2020-11-25 10:33 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
https://gcc.gnu.org/g:ad9cbcee543ecccd79fa49dafcd925532d2ce210
commit r11-5330-gad9cbcee543ecccd79fa49dafcd925532d2ce210
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Nov 25 10:26:09 2020 +0000
libstdc++: Fix handling of futex wake [PR 97936]
The __platform_wait function is supposed to wait until *addr != old.
The futex syscall checks the initial value and returns EAGAIN if *addr
!= old is already true, which should cause __platform_wait to return.
Instead it loops and keeps doing a futex wait, which keeps returning
EAGAIN.
libstdc++-v3/ChangeLog:
PR libstdc++/97936
* include/bits/atomic_wait.h (__platform_wait): Return if futex
sets EAGAIN.
* testsuite/30_threads/latch/3.cc: Re-enable test.
* testsuite/30_threads/semaphore/try_acquire_until.cc: Likewise.
Diff:
---
libstdc++-v3/include/bits/atomic_wait.h | 4 ++--
libstdc++-v3/testsuite/30_threads/latch/3.cc | 1 -
libstdc++-v3/testsuite/30_threads/semaphore/try_acquire_until.cc | 1 -
3 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/libstdc++-v3/include/bits/atomic_wait.h b/libstdc++-v3/include/bits/atomic_wait.h
index cd756f68de6..fdf7c4586f2 100644
--- a/libstdc++-v3/include/bits/atomic_wait.h
+++ b/libstdc++-v3/include/bits/atomic_wait.h
@@ -100,9 +100,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
auto __e = syscall (SYS_futex, static_cast<const void*>(__addr),
static_cast<int>(__futex_wait_flags::__wait_private),
__val, nullptr);
- if (!__e)
+ if (!__e || EAGAIN)
break;
- else if (!(errno == EINTR || errno == EAGAIN))
+ else if (errno != EINTR)
__throw_system_error(__e);
}
}
diff --git a/libstdc++-v3/testsuite/30_threads/latch/3.cc b/libstdc++-v3/testsuite/30_threads/latch/3.cc
index 6304135a877..70f2d183e87 100644
--- a/libstdc++-v3/testsuite/30_threads/latch/3.cc
+++ b/libstdc++-v3/testsuite/30_threads/latch/3.cc
@@ -19,7 +19,6 @@
// { dg-do run { target c++2a } }
// { dg-require-gthreads "" }
// { dg-additional-options "-pthread" { target pthread } }
-// { dg-skip-if "broken" { *-*-* } }
#include <latch>
#include <atomic>
diff --git a/libstdc++-v3/testsuite/30_threads/semaphore/try_acquire_until.cc b/libstdc++-v3/testsuite/30_threads/semaphore/try_acquire_until.cc
index 5e1141425f7..58f68ce9e1e 100644
--- a/libstdc++-v3/testsuite/30_threads/semaphore/try_acquire_until.cc
+++ b/libstdc++-v3/testsuite/30_threads/semaphore/try_acquire_until.cc
@@ -19,7 +19,6 @@
// { dg-do run { target c++2a } }
// { dg-require-gthreads "" }
// { dg-additional-options "-pthread" { target pthread } }
-// { dg-skip-if "broken" { *-*-* } }
#include <semaphore>
#include <chrono>
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-11-25 10:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-25 10:33 [gcc r11-5330] libstdc++: Fix handling of futex wake [PR 97936] Jonathan Wakely
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).