[libc-commits] [libunwind] [compiler-rt] [mlir] [llvm] [lld] [flang] [lldb] [libcxx] [libcxxabi] [clang] [libc] [clang-tools-extra] [asan] Install `pthread_atfork` (PR #75290)

Rainer Orth via libc-commits libc-commits at lists.llvm.org
Fri Dec 15 01:23:26 PST 2023


rorth wrote:

Since this patch, all asan tests loop on Solaris.  This had been hidden for a bit by an unrelated extended build breakage on the bots, but now every `ninja check-all` on the Solaris/amd64 bot times out.  I could trace this to this patch.

E.g. when running `projects/compiler-rt/test/asan/I386SunOSConfig/TestCases/Output/alloca_big_alignment.cpp.tmp`, I get the expected output
```
=================================================================
==22223==ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address 0xfeffd88a at pc 0x0812907d bp 0xfeffd7f4 sp 0xfeffd7ec
WRITE of size 1 at 0xfeffd88a thread T0
```
and afterwards the test loops.  `truss` shows an unending series of
```
22210:	yield()						= 0
22210:	yield()						= 0
22210:	yield()						= 0
```
and `pstack` gives
```
22213:	/var/llvm/local-amd64-release-stage2-A-flang-492214/tools/clang/stage2
 fdfbebc5 yield    (0x8139158, 0x8109558, 0x818a580, 0x0, 0x5dd, 0x8139158) + 15
 0810cd32 __sanitizer::FutexWait(__sanitizer::atomic_uint32_t*, unsigned int) (0xfe00a000, 0xfdebdd56, 0x805ad7c, 0xfdfa0107, 0xfeffc68c, 0x5) + 12
 080f4952 __asan::InstallAtForkHandler()::$_0::__invoke() (0xfde26fc0, 0x7, 0xfe010200, 0xfe010140, 0x7, 0x5) + 12
 fdfa49c8 forkx    (0x0, 0xfe5ad000, 0x89f, 0xfdfa4b8c) + c8
 fdfa4b9d fork     (0x8139158, 0x811563e, 0xfeffc720, 0xfd6007a0, 0x4, 0x8139158) + 1d
 0810ccd2 __sanitizer::internal_fork() () + 12
```
This seems no wonder given that `sanitizer_common/sanitizer_solaris.cpp` has
```
void FutexWait(atomic_uint32_t *p, u32 cmp) {
  // FIXME: implement actual blocking.
  sched_yield();
}
```
`sanitizer_mac.cpp` is the same, btw., and even `sanitizer_linux.cpp` has
```
#  if !SANITIZER_SOLARIS
void FutexWait(atomic_uint32_t *p, u32 cmp) {
#    if SANITIZER_FREEBSD
  _umtx_op(p, UMTX_OP_WAIT_UINT, cmp, 0, 0);
#    elif SANITIZER_NETBSD
  sched_yield(); /* No userspace futex-like synchronization */
#    else
  internal_syscall(SYSCALL(futex), (uptr)p, FUTEX_WAIT_PRIVATE, cmp, 0, 0, 0);
#    endif
}
```
so even NetBSD would be affected.

https://github.com/llvm/llvm-project/pull/75290


More information about the libc-commits mailing list