#include "threads/thread.hpp"
#include "vm/jit/builtin.hpp"
-#include "vm/signallocal.h"
+#include "vm/signallocal.hpp"
#include "vm/jit/asmpart.h"
#include "vm/jit/executionstate.h"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
#include "vm/jit/stacktrace.hpp"
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;