aboutsummaryrefslogtreecommitdiff
path: root/openmp/runtime/src/z_Linux_util.cpp
diff options
context:
space:
mode:
authorAndreyChurbanov <andrey.churbanov@intel.com>2022-05-19 12:06:01 -0500
committerJonathan Peyton <jonathan.l.peyton@intel.com>2022-07-19 12:59:58 -0500
commita01d274fbd44b49bf6c5af9cce49f706b31fab76 (patch)
treea4faf69c16b31d5bc909c8612088b5ef60c995f4 /openmp/runtime/src/z_Linux_util.cpp
parent6fb27bc2e3eac45d597bfc9285e5e1cb8ca16a60 (diff)
downloadllvm-a01d274fbd44b49bf6c5af9cce49f706b31fab76.zip
llvm-a01d274fbd44b49bf6c5af9cce49f706b31fab76.tar.gz
llvm-a01d274fbd44b49bf6c5af9cce49f706b31fab76.tar.bz2
[OpenMP][libomp] Fix /dev/shm pollution after forked child process terminates
Made library registration conditional and skip it in the __kmp_atfork_child handler, postponed it till middle initialization in the child. This fixes the problem of applications those use e.g. popen/pclose which terminate the forked child process. Differential Revision: https://reviews.llvm.org/D125996
Diffstat (limited to 'openmp/runtime/src/z_Linux_util.cpp')
-rw-r--r--openmp/runtime/src/z_Linux_util.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp
index 5cd6ad6..91edf025 100644
--- a/openmp/runtime/src/z_Linux_util.cpp
+++ b/openmp/runtime/src/z_Linux_util.cpp
@@ -1297,7 +1297,13 @@ static void __kmp_atfork_child(void) {
__kmp_itt_reset(); // reset ITT's global state
#endif /* USE_ITT_BUILD */
- __kmp_serial_initialize();
+ {
+ // Child process often get terminated without any use of OpenMP. That might
+ // cause mapped shared memory file to be left unattended. Thus we postpone
+ // library registration till middle initialization in the child process.
+ __kmp_need_register_serial = FALSE;
+ __kmp_serial_initialize();
+ }
/* This is necessary to make sure no stale data is left around */
/* AC: customers complain that we use unsafe routines in the atfork