merged volatile memory barriers
[cacao.git] / src / vm / jit / i386 / freebsd / md-os.c
index 43800e6b1b4954217b7b2b33c318b3608118b508..a65dd4a2c894f609c51f2c658479019c247688de 100644 (file)
@@ -225,6 +225,22 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
        xpc = (u1 *) _mc->mc_eip;
        ra  = xpc;                            /* return address is equal to xpc   */
 
+       // Check if the trap instruction is valid.
+       // TODO Move this into patcher_handler.
+       if (patcher_is_valid_trap_instruction_at(xpc) == false) {
+               // Check if the PC has been patched during our way to this
+               // signal handler (see PR85).
+               if (patcher_is_patched_at(xpc) == true)
+                       return;
+
+               // We have a problem...
+               log_println("md_signal_handler_sigill: Unknown illegal instruction at 0x%lx", xpc);
+#if defined(ENABLE_DISASSEMBLER)
+               (void) disassinstr(xpc);
+#endif
+               vm_abort("Aborting...");
+       }
+
        type = TRAP_PATCHER;
        val  = 0;
 
@@ -234,33 +250,6 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
 }
 
 
-/* md_signal_handler_sigusr1 ***************************************************
-
-   Signal handler for suspending threads.
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
-void md_signal_handler_sigusr1(int sig, siginfo_t *siginfo, void *_p)
-{
-       ucontext_t *_uc;
-       mcontext_t *_mc;
-       u1         *pc;
-       u1         *sp;
-
-       _uc = (ucontext_t *) _p;
-       _mc = &_uc->uc_mcontext;
-
-       /* get the PC and SP for this thread */
-       pc = (u1 *) _mc->mc_eip;
-       sp = (u1 *) _mc->mc_esp;
-
-       /* now suspend the current thread */
-       threads_suspend_ack(pc, sp);
-}
-#endif
-
-
 /* md_signal_handler_sigusr2 ***************************************************
 
    Signal handler for profiling sampling.