summaryrefslogtreecommitdiffstats
path: root/loader2
diff options
context:
space:
mode:
authorJeremy Katz <katzj@redhat.com>2005-12-20 20:23:25 +0000
committerJeremy Katz <katzj@redhat.com>2005-12-20 20:23:25 +0000
commita703d87ae20c34a05029d37d7fdaf5f117a643ac (patch)
treea88101475f375749a84b60f3e2265fc12c3cf782 /loader2
parentc601be0c36205a11964d91f67c5369c01af34360 (diff)
downloadanaconda-a703d87ae20c34a05029d37d7fdaf5f117a643ac.tar.gz
anaconda-a703d87ae20c34a05029d37d7fdaf5f117a643ac.tar.xz
anaconda-a703d87ae20c34a05029d37d7fdaf5f117a643ac.zip
2005-12-20 Jeremy Katz <katzj@redhat.com>
* loader2/loader.c: Give a stacktrace on SIGSEGV to make things easier to debug.
Diffstat (limited to 'loader2')
-rw-r--r--loader2/loader.c24
1 files changed, 24 insertions, 0 deletions
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);