[ORC-RT][MachO] Unlock JDStatesMutex during push-initializers to avoid deadlock.
authorLang Hames <lhames@gmail.com>
Fri, 11 Nov 2022 21:34:29 +0000 (13:34 -0800)
committerLang Hames <lhames@gmail.com>
Sat, 12 Nov 2022 00:01:25 +0000 (16:01 -0800)
commite7707464a3f7bf0c6011809d80d0a6e525be184b
tree921652138cd0b4bd2bd1f7c8b5a42afab52cfbf4
parent5f479ee7fc7a3a311cd62642de655c08321af981
[ORC-RT][MachO] Unlock JDStatesMutex during push-initializers to avoid deadlock.

During __orc_rt_macho_jit_dlopen the ORC runtime will make a request to the JIT
to push any new initializers. Since this call may add new JD-state to the
runtime (and is expected to in general) we need to unlock the JDStatesMutex
during this operation (and similarly when running initializers and atexits, as
these may call trigger push-initializers recursively).

No testcase yet: I haven't been able to reproduce the deadlock when running
llvm-jitlink in in-process mode, and we don't support out-of-process mode in
regression tests yet.
compiler-rt/lib/orc/macho_platform.cpp