trap: sigception: allow signal in signal handler context
authorBernhard Urban <lewurm@gmail.com>
Wed, 25 Apr 2012 21:47:46 +0000 (23:47 +0200)
committerBernhard Urban <lewurm@gmail.com>
Wed, 25 Apr 2012 21:53:09 +0000 (23:53 +0200)
this can hapen in combination with the static initializer:
(1) some code in class B wants to access a static field in class A
(2) SEGSEGV is issued.  we are in a signal context now
(3) this is the first usage of class A, so we have to load it
    and execute the static initializer
(4) in the static initializer of class A, there is also a static
    field access, which again causes a SIGSEGV

without `SA_NODEFER', the second SIGSEGV would be ignored.

ffi/trap.c

index 228b2c36f3e96d1122f9b7ec74ed631ca2d8b5c3..9d70492cb2b292eb12f7c7935acd62655f478a65 100644 (file)
@@ -110,13 +110,13 @@ void register_signal(void)
        struct sigaction illaction;
        illaction.sa_sigaction = callertrap;
        sigemptyset(&illaction.sa_mask);
-       illaction.sa_flags = SA_SIGINFO | SA_RESTART;
+       illaction.sa_flags = SA_SIGINFO | SA_RESTART | SA_NODEFER;
        sigaction(SIGILL, &illaction, NULL);
 
        struct sigaction segvaction;
        segvaction.sa_sigaction = staticfieldtrap;
        sigemptyset(&segvaction.sa_mask);
-       segvaction.sa_flags = SA_SIGINFO | SA_RESTART;
+       segvaction.sa_flags = SA_SIGINFO | SA_RESTART | SA_NODEFER;
        sigaction(SIGSEGV, &segvaction, NULL);
 }