PR85 for x86_64.
[cacao.git] / src / vm / jit / x86_64 / linux / md-os.c
index 78ff29675028ceb08ab71c3d2b1f07e0b177ff23..1c30b8bbf94fac72d746b7f3256e047461f258f6 100644 (file)
@@ -260,6 +260,22 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
        xpc = (u1 *) _mc->gregs[REG_RIP];
        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...");
+       }
+
        /* This is a patcher. */
 
        type = TRAP_PATCHER;