Go to file
Mike Crowe a39fec8c74
libstdc++: shared_mutex: Respond consistently to errors and deadlock
Make the shared_mutex::try_lock(), shared_timed_mutex::try_lock_until()
and shared_timed_mutex::try_lock_shared_until() all handle errors from
pthread functions consistently by returning false to indicate that the
lock could not be taken. If _GLIBCXX_ASSERTIONS is defined then
unexpected errors, such as EDEADLK and EINVAL will cause an assertion
failure. If _GLIBCXX_ASSERTIONS is not defined then these functions no
longer ever return true incorrectly indicating that they have taken the
lock.

This removes the previous behaviour of looping on EDEADLK in
try_lock_shared_until() and no longer returns true on EINVAL in all of
these functions. (In theory at least it should not be possible to
trigger EINVAL since 5dba17a3e709859968f939354e6e5e8d796012d3.)

Unfortunately my reading of POSIX is that pthread_rwlock_clockrdlock[1],
pthread_rwlock_timedrdlock pthread_rwlock_clockwrlock[2] and
pthread_rwlock_timedwrlock are allowed to deadlock rather than return
EDEADLK when trying to take a lock a second time from the same
thread. This means that the deadlock tests cannot be enabled by
default. I believe that the tests do work with glibc (2.31 & 2.36) and
with the __shared_mutex_cv implementation though.

[1] https://pubs.opengroup.org/onlinepubs/9799919799/functions/pthread_rwlock_clockrdlock.html
[2] https://pubs.opengroup.org/onlinepubs/9799919799/functions/pthread_rwlock_clockwrlock.html

libstdc++-v3/ChangeLog:

	* include/std/shared_mutex (try_lock, try_lock_until)
	(try_lock_shared_until): Respond consistently to errors and
	deadlocks.
	* testsuite/30_threads/shared_timed_mutex/try_lock_until/116586.cc:
	Test deadlock behaviour if possible.

Signed-off-by: Mike Crowe <mac@mcrowe.com>
2025-11-18 17:13:44 +00:00
.forgejo top-level: Add forgejo sanity checks 2025-10-20 10:46:55 +00:00
.github
INSTALL
c++tools
config Daily bump. 2025-11-04 00:20:26 +00:00
contrib Daily bump. 2025-11-17 00:19:25 +00:00
fixincludes Daily bump. 2025-08-29 00:19:55 +00:00
gcc c++: Handle absolute path for CMI output directory [PR122677] 2025-11-18 17:10:47 +00:00
gnattools Daily bump. 2025-06-23 00:16:33 +00:00
gotools
include Daily bump. 2025-11-14 00:20:34 +00:00
libada
libatomic Daily bump. 2025-11-14 00:20:34 +00:00
libbacktrace Daily bump. 2025-11-07 00:20:18 +00:00
libcc1 Daily bump. 2025-11-04 00:20:26 +00:00
libcody Daily bump. 2025-11-18 00:21:51 +00:00
libcpp Daily bump. 2025-11-11 00:21:25 +00:00
libdecnumber
libffi Daily bump. 2025-11-04 00:20:26 +00:00
libgcc Daily bump. 2025-11-12 00:22:41 +00:00
libgcobol Daily bump. 2025-11-18 00:21:51 +00:00
libgfortran Daily bump. 2025-11-12 00:22:41 +00:00
libgm2 Daily bump. 2025-11-04 00:20:26 +00:00
libgo runtime: avoid libc memmove and memclr 2025-07-08 15:49:16 -07:00
libgomp Daily bump. 2025-11-18 00:21:51 +00:00
libgrust Daily bump. 2025-11-04 00:20:26 +00:00
libiberty Daily bump. 2025-11-07 00:20:18 +00:00
libitm Daily bump. 2025-11-04 00:20:26 +00:00
libobjc Daily bump. 2025-11-04 00:20:26 +00:00
libphobos Daily bump. 2025-11-04 00:20:26 +00:00
libquadmath Daily bump. 2025-11-04 00:20:26 +00:00
libsanitizer Daily bump. 2025-11-04 00:20:26 +00:00
libssp Daily bump. 2025-11-04 00:20:26 +00:00
libstdc++-v3 libstdc++: shared_mutex: Respond consistently to errors and deadlock 2025-11-18 17:13:44 +00:00
libvtv Daily bump. 2025-11-04 00:20:26 +00:00
lto-plugin Daily bump. 2025-11-04 00:20:26 +00:00
maintainer-scripts Daily bump. 2025-09-02 00:19:26 +00:00
zlib Daily bump. 2025-11-04 00:20:26 +00:00
.b4-config
.dir-locals.el
.editorconfig editorconfig: Add explicit tab_width when indent_size != 8 2025-10-28 15:06:51 +00:00
.gitattributes
.gitignore Rust: Move 'libformat_parser' build into the GCC build directory 2025-08-05 16:36:43 +02:00
ABOUT-NLS
COPYING
COPYING.LIB
COPYING.RUNTIME
COPYING3
COPYING3.LIB
ChangeLog Daily bump. 2025-11-17 00:19:25 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
MAINTAINERS MAINTAINERS: Add myself to reviewers/maintainers. 2025-10-30 15:54:29 +01:00
Makefile.def PR81358: Enable automatic linking of libatomic. 2025-10-09 07:26:51 +00:00
Makefile.in Simplify 'Makefile' dependencies for libatomic [PR81358] 2025-10-24 12:40:22 +02:00
Makefile.tpl Simplify 'Makefile' dependencies for libatomic [PR81358] 2025-10-24 12:40:22 +02:00
README
SECURITY.txt
ar-lib
compile
config-ml.in *: Fix patch email address 2025-10-11 11:08:01 +02:00
config.guess
config.rpath
config.sub
configure Remove /usr/ccs references on Solaris 2025-11-16 14:00:11 +01:00
configure.ac Remove /usr/ccs references on Solaris 2025-11-16 14:00:11 +01:00
depcomp
install-sh
libtool-ldflags
libtool.m4 Sync toplevel files from binutils-gdb 2025-10-02 15:00:06 +08:00
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
symlink-tree *: Fix patch email address 2025-10-11 11:08:01 +02:00
test-driver
ylwrap

README

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.