]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pid1: add comment to crash handler about memory allocations
authorLennart Poettering <lennart@poettering.net>
Thu, 10 Mar 2022 08:22:32 +0000 (09:22 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 10 Mar 2022 12:45:09 +0000 (13:45 +0100)
src/core/main.c

index 7c9265f394e2d080e38432964e924975678c3f00..fc524867ef6117e2c1d545a0e3ec95647ac63550 100644 (file)
@@ -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);