From dd2e112169f5ee7cf5c34c4699820fb4f6a7f8de Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Mon, 13 Dec 2021 14:46:58 -0500 Subject: [PATCH] sanitizers: disable calls to pthread_atfork OpenBLAS tries to do bad things in this callback (supposedly to support use-after-fork), so we disable it entirely for TSAN/ASAN, where it causes the sanitizers to deadlock. --- cli/loader_exe.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cli/loader_exe.c b/cli/loader_exe.c index 983cef02fa037..07a0bddcd4b87 100644 --- a/cli/loader_exe.c +++ b/cli/loader_exe.c @@ -63,6 +63,15 @@ int main(int argc, char * argv[]) return ret; } +#if defined(__GLIBC__) && (defined(_COMPILER_ASAN_ENABLED_) || defined(_COMPILER_TSAN_ENABLED_)) +// fork is generally bad news, but it is better if we prevent applications from +// making it worse as openblas threadpools cause it to hang +int __register_atfork232(void (*prepare)(void), void (*parent)(void), void (*child)(void), void *dso_handle) { + return 0; +} +__asm__ (".symver __register_atfork232, __register_atfork@@GLIBC_2.3.2"); +#endif + #ifdef __cplusplus } // extern "C" #endif