diff options
author | Jean-Louis Fuchs <jean-louis.fuchs@adfinis-sygroup.ch> | 2020-09-28 14:45:15 +0200 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2021-12-17 12:55:33 +0000 |
commit | d13349f25ce6160695237cb1715bc3a8e2fa8985 (patch) | |
tree | 1b27b074b6d14bc6dc5a38f44b887ea8c79961ad | |
parent | ac6e6cb68a06ec022f994899dc8f490a030b4060 (diff) | |
download | dbus-d13349f25ce6160695237cb1715bc3a8e2fa8985.tar.gz |
disable fork-malloc-exec for non-glibc-systems
Calling malloc() after fork is undefined behaviour if the process is
multi-threaded. locks held by a thread on fork() will never be released.
malloc() is usally protected by a lock and can therefore deadlock. glibc
is known not to deadlock in this case.
This commit does not rule out other problems on glibc-systems, but fixes an
issue on musl-libc-systems. Only restricting to async-signal safe functions
between fork() and exec() prevents undefined behaviour for sure. See
signal-safety(7).
(cherry picked from commit 3fab06d68f5940cde89fb9c7e647bdc48bc7b253)
-rw-r--r-- | dbus/dbus-sysdeps-unix.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index e511afc5..06cea5a0 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -4471,7 +4471,7 @@ _dbus_close_all (void) { int maxfds, i; -#ifdef __linux__ +#if defined(__linux__) && defined(__GLIBC__) DIR *d; /* On Linux we can optimize this a bit if /proc is available. If it |