[Bug 271490] Deadlock between _rtld_atfork_pre and _thr_attr_init

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 19 May 2023 11:56:04 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=271490

--- Comment #9 from KJ Tsanaktsidis <kj@kjtsanaktsidis.id.au> ---
Ahah! I managed to make an isolated program which causes the issue. See the
file `reproduction.c` I added as an attachment.

This will eventually hang not printing anything, and attaching GDB to the child
process (not the parent) will show a similar stack trace going through
`_rtld_atfork_pre`:

```
clang -std=c11 reproduction.c -lpthread -o reproduction
while true; do ./reproduction; done;
```

However, this will _NOT_ hang:

```
while true; do LD_BIND_NOW=yes ./reproduction; done;
```

(on my machine, in any case).

The trick seems to be doing a multithreaded fork, followed by _another_
multithreaded fork.

Thanks again for having a look at this Konstantin!

-- 
You are receiving this mail because:
You are the assignee for the bug.