History

um: fix abort

os_dump_core() uses abort() to terminate UML in case of an fatal error. glibc's abort() calls raise(SIGABRT) which makes use of tgkill(). tgkill() has no effect within UML's kernel threads because they are not pthreads. As fallback abort() executes an invalid instruction to terminate the process. Therefore UML gets killed by SIGSEGV and leaves a ugly log entry in the host's kernel ring buffer. To get rid of this we use our own abort routine.

Richard Weinberger committed 15 years ago

Commit b2db2191 parent d6c438b1 file · +22 −1Browse files

Unified · Split

arch/um/os-Linux/util.c+22−1
@@ -5,6 +5,7 @@ · 4 unmodified lines
55
66 #include <stdio.h>
77 #include <stdlib.h>
8+#include <unistd.h>
89 #include <errno.h>
910 #include <signal.h>
1011 #include <string.h>
@@ -75,6 +76,26 @@ void setup_hostinfo(char *buf, int len) · 64 unmodified lines
7576 host.release, host.version, host.machine);
7677 }
7778
79+/*
80+ * We cannot use glibc's abort(). It makes use of tgkill() which
81+ * has no effect within UML's kernel threads.
82+ * After that glibc would execute an invalid instruction to kill
83+ * the calling process and UML crashes with SIGSEGV.
84+ */
85+static inline void __attribute__ ((noreturn)) uml_abort(void)
86+{
87+ sigset_t sig;
88+
89+ fflush(NULL);
90+
91+ if (!sigemptyset(&sig) && !sigaddset(&sig, SIGABRT))
92+ sigprocmask(SIG_UNBLOCK, &sig, 0);
93+
94+ for (;;)
95+ if (kill(getpid(), SIGABRT) < 0)
96+ exit(127);
97+}
98+
7899 void os_dump_core(void)
79100 {
80101 int pid;
@@ -116,5 +137,5 @@ void os_dump_core(void) · 35 unmodified lines
116137 while ((pid = waitpid(-1, NULL, WNOHANG | __WALL)) > 0)
117138 os_kill_ptraced_process(pid, 0);
118139
119− abort();
140+ uml_abort();
120141 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t