wow, this is a nasty bug...
authorBrian Demsky <bdemsky@uci.edu>
Thu, 24 May 2012 20:32:55 +0000 (13:32 -0700)
committerBrian Demsky <bdemsky@uci.edu>
Thu, 24 May 2012 20:32:55 +0000 (13:32 -0700)
the last part of the snapshot bug is the following:
we snapshot the user threads stack...  when we get a seg fault,
the signal handler is using the same write protected stack...
obviously this is going to cause problems.  luckily there is support
for a special stack for the signal handler.  this checkin switches
the signal handler to run on a different stack than the program stack.

snapshot.cc
snapshot.h

index 20980015fe50d9678e67a606f37e2a3b934aa3e6..7105d2c6a170905bc3dc4250ea3c3b365381db01 100644 (file)
@@ -134,8 +134,15 @@ extern "C" {
 #endif
 void initSnapShotLibrary(unsigned int numbackingpages, unsigned int numsnapshots, unsigned int nummemoryregions, unsigned int numheappages, MyFuncPtr entryPoint){
 #if USE_CHECKPOINTING
+  /* Setup a stack for our signal handler....  */
+  stack_t ss;
+  ss.ss_sp = MYMALLOC(SIGSTACKSIZE);
+  ss.ss_size = SIGSTACKSIZE;
+  ss.ss_flags = 0;
+  sigaltstack(&ss, NULL);
+
        struct sigaction sa;
-       sa.sa_flags = SA_SIGINFO | SA_NODEFER | SA_RESTART;
+       sa.sa_flags = SA_SIGINFO | SA_NODEFER | SA_RESTART | SA_ONSTACK;
        sigemptyset( &sa.sa_mask );
        sa.sa_sigaction = HandlePF;
        if( sigaction( SIGSEGV, &sa, NULL ) == -1 ){
index 4625c5d5cfaa7c39cd03087462da86858da0c371..819ea0a41b79ca25782b50e9f109df68b35dc041 100644 (file)
@@ -2,6 +2,8 @@
 #define _SNAPSHOT_H
 #define PAGESIZE 4096
 #define USE_CHECKPOINTING 1
+/* Size of signal stack */
+#define SIGSTACKSIZE 16384
 
 
 typedef unsigned int snapshot_id;