[Bug 271490] Deadlock between _rtld_atfork_pre and _thr_attr_init
- In reply to: bugzilla-noreply_a_freebsd.org: "[Bug 271490] Deadlock between _rtld_atfork_pre and _thr_attr_init"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 19 May 2023 11:24:49 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=271490 --- Comment #7 from KJ Tsanaktsidis <kj@kjtsanaktsidis.id.au> --- I did make a bit more progress debugging the issue though - I don't think the problem has anything to do with jemalloc at all - it's _just_ an RTLD issue. I captured a different backtrace of the problem and attached it. In this one thread #2 is just sitting there chilling on an unrelated mutex; it is _not_ doing any jemalloc things. So, thread #1 manages to get deadlocked during `_rtld_atfork_pre` all by itself. In particular, it's blocked acquiring the `rtld_bind_lock` in write mode, and the lock appears to already be held in write mode (by who??): ``` (gdb) print *((struct rtld_lock *)lock) $21 = {lock = {rw_state = -1610612736, rw_flags = 2, rw_blocked_readers = 1, rw_blocked_writers = 0, rw_spare = {0, 0, 0, 0}}, _pad = '\000' <repeats 31 times>} # bitmask against URWLOCK constants, from https://github.com/freebsd/freebsd-src/blob/1377eb268a5a8a5573bda33a651963259c43c3ed/sys/sys/umtx.h#L62 (gdb) print /x ((struct rtld_lock *)lock)->lock.rw_state & 0x80000000U $22 = 0x80000000 (gdb) print /x ((struct rtld_lock *)lock)->lock.rw_state & 0x40000000U $23 = 0x0 (gdb) print /x ((struct rtld_lock *)lock)->lock.rw_state & 0x1FFFFFFFU $24 = 0x0 (gdb) ``` Also also, I'm not 100% sure yet that this wasn't just luck so far, but it _seems_ I can avoid the deadlock by setting `LD_BIND_NOW`... Anyway I'll keep hunting for an isolated reproduction. If you have a stab in the dark though I'm happy to try a patch as well. -- You are receiving this mail because: You are the assignee for the bug.