From: Paul Floyd Date: Tue, 28 Feb 2023 21:17:25 +0000 (+0100) Subject: Bug 445743 - "The impossible happened: mutex is locked simultaneously by two threads... X-Git-Tag: VALGRIND_3_21_0~156 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=94a41e050c92a504515c66ebdaf84cad91c869bb;p=valgrind.git Bug 445743 - "The impossible happened: mutex is locked simultaneously by two threads" while using mutexes with priority inheritance and signals Been using the same fix in FreeBSD for quite a while, so I think it's safe to apply to Linux and close the bugzi item. --- diff --git a/NEWS b/NEWS index c6ebdcb252..e31fc3c50d 100644 --- a/NEWS +++ b/NEWS @@ -87,6 +87,8 @@ are not entered into bugzilla tend to get forgotten about or ignored. 444110 priv/guest_ppc_toIR.c:36198:31: warning: duplicated 'if' condition. 444488 Use glibc.pthread.stack_cache_size tunable 444568 drd/tests/pth_barrier_thr_cr fails on Fedora 38 +445743 "The impossible happened: mutex is locked simultaneously by two threads" + while using mutexes with priority inheritance and signals 459476 vgdb: allow address reuse to avoid "address already in use" errorsuse" errors 460356 s390: Sqrt32Fx4 -- cannot reduce tree 462830 WARNING: unhandled amd64-freebsd syscall: 474 @@ -95,7 +97,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 464859 Build failures with GCC-13 (drd tsan_unittest) 464969 D language demangling 465435 m_libcfile.c:66 (vgPlain_safe_fd): Assertion 'newfd >= VG_(fd_hard_limit)' failed. -n-i-bz FreeBSD rfork syscall fail with EINVAL or EINVAL rather than VG_(unimplemented) +n-i-bz FreeBSD rfork syscall fail with EINVAL or ENOSYS rather than VG_(unimplemented) To see details of a given bug, visit https://bugs.kde.org/show_bug.cgi?id=XXXXXX diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index bb87c90bab..4a5a93b35a 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -1743,6 +1743,9 @@ static void futex_pre_helper ( ThreadId tid, SyscallArgLayout* layout, } *flags |= SfMayBlock; + if ((ARG2 & (VKI_FUTEX_PRIVATE_FLAG|VKI_FUTEX_LOCK_PI)) == (VKI_FUTEX_PRIVATE_FLAG|VKI_FUTEX_LOCK_PI)) { + *flags |= SfKernelRestart; + } switch(ARG2 & ~(VKI_FUTEX_PRIVATE_FLAG|VKI_FUTEX_CLOCK_REALTIME)) { case VKI_FUTEX_WAIT: