From: Lennart Poettering Date: Thu, 10 Mar 2022 08:22:32 +0000 (+0100) Subject: pid1: add comment to crash handler about memory allocations X-Git-Tag: v251-rc1~177^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4fba096ba106a5629ae9a1ed895a744b974e56ca;p=thirdparty%2Fsystemd.git pid1: add comment to crash handler about memory allocations --- diff --git a/src/core/main.c b/src/core/main.c index 7c9265f394e..fc524867ef6 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -232,6 +232,12 @@ _noreturn_ static void crash(int sig, siginfo_t *siginfo, void *context) { struct sigaction sa; pid_t pid; + /* NB: 💣 💣 💣 This is a signal handler, most likely executed in a situation where we have corrupted + * memory. Thus: please avoid any libc memory allocation here, or any functions that internally use + * memory allocation, as we cannot rely on memory allocation still working at this point! (Note that + * memory allocation is not async-signal-safe anyway — see signal-safety(7) for details —, and thus + * is not permissible in signal handlers.) */ + if (getpid_cached() != 1) /* Pass this on immediately, if this is not PID 1 */ (void) raise(sig);