diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | loader2/loader.c | 24 |
2 files changed, 29 insertions, 0 deletions
@@ -1,3 +1,8 @@ +2005-12-20 Jeremy Katz <katzj@redhat.com> + + * loader2/loader.c: Give a stacktrace on SIGSEGV to make things + easier to debug. + 2005-12-20 Bill Nottingham <notting@redhat.com> * iutil.py (getPPCMachine): Be silent on non-ppc arches. diff --git a/loader2/loader.c b/loader2/loader.c index 098f99f0c..f722e5b01 100644 --- a/loader2/loader.c +++ b/loader2/loader.c @@ -24,6 +24,7 @@ #include <ctype.h> #include <errno.h> +#include <execinfo.h> #include <fcntl.h> #include <newt.h> #include <popt.h> @@ -1138,6 +1139,26 @@ static int hasGraphicalOverride() { return 0; } +static void loaderSegvHandler(int signum) { + void *array[10]; + size_t size; + char **strings; + size_t i; + + signal(SIGSEGV, SIG_DFL); /* back to default */ + + newtFinished(); + size = backtrace (array, 10); + strings = backtrace_symbols (array, size); + + printf ("loader received SIGSEGV!. Backtrace:\n"); + for (i = 0; i < size; i++) + printf ("%s\n", strings[i]); + + free (strings); + exit(1); +} + int main(int argc, char ** argv) { int flags = LOADER_FLAGS_SELINUX | LOADER_FLAGS_NOFB; struct stat sb; @@ -1175,6 +1196,9 @@ int main(int argc, char ** argv) { { 0, 0, 0, 0, 0, 0, 0 } }; + /* set up signal handler */ + signal(SIGSEGV, loaderSegvHandler); + /* Make sure sort order is right. */ setenv ("LC_COLLATE", "C", 1); |