Skip to content

Instantly share code, notes, and snippets.

Created September 13, 2012 01:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3711149 to your computer and use it in GitHub Desktop.
Save anonymous/3711149 to your computer and use it in GitHub Desktop.
debugging sigpfe in qemu/rbd
From eac2fbddb0f39f4780ac42e009ce60d56c78cb76 Mon Sep 17 00:00:00 2001
From: Josh Durgin <josh.durgin@inktank.com>
Date: Wed, 12 Sep 2012 17:39:57 -0700
Subject: [PATCH] print debug info for SIGPFE
---
main-loop.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/main-loop.c b/main-loop.c
index eb3b6e6..c624172 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -130,10 +130,18 @@ static void sigfd_handler(void *opaque)
}
}
+static void debug_sigfpe(int signo, siginfo_t *info, void *opaque)
+{
+ printf("got SIGFPE! si_code = %d address = %p\n", info->si_code,
+ info->si_addr);
+ abort();
+}
+
static int qemu_signal_init(void)
{
int sigfd;
sigset_t set;
+ struct sigaction action;
/*
* SIG_IPI must be blocked in the main thread and must not be caught
@@ -147,7 +155,11 @@ static int qemu_signal_init(void)
sigaddset(&set, SIGBUS);
pthread_sigmask(SIG_BLOCK, &set, NULL);
+ action.sa_flags = SA_SIGINFO;
+ action.sa_sigaction = debug_sigfpe;
+ sigaction(SIGFPE, &action, NULL);
sigdelset(&set, SIG_IPI);
+ sigaddset(&set, SIGFPE);
sigfd = qemu_signalfd(&set);
if (sigfd == -1) {
fprintf(stderr, "failed to create signalfd\n");
--
1.7.2.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment