From c3af3cf3704ce01c71de96cc36c2798014fc9960 Mon Sep 17 00:00:00 2001 From: Alastair Bridgewater Date: Mon, 24 Oct 2011 14:30:32 -0400 Subject: [PATCH] Fix x86oid OSX signal handling emulation assembly fragments. * Both x86 and x86-64 signal_emulation_wrapper include a small assembly fragment to simulate "sigreturn" by means of an invalid instruction trap. This fragment has to load two different pointers into specific registers before the trap, but historically just told the compiler to load them into registers and then moved them into the correct registers, leading to the possibility of clobbering one of the values. Fixed, by informing the compiler to place them into the correct registers to begin with. --- NEWS | 2 ++ src/runtime/x86-64-darwin-os.c | 4 ++-- src/runtime/x86-darwin-os.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index b141253..eaba678 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,8 @@ changes relative to sbcl-1.0.52: of multiple-valued places to be set to NIL, instead of signalling an error (per a careful reading of CLHS 5.1.2.3). * bug fix: floating-point traps now work on darwin/x86-64. + * bug fix: repair crash in x86oid darwin signal handling emulation + when built with certain compilers. changes in sbcl-1.0.52 relative to sbcl-1.0.51: * enhancement: ASDF has been updated to version 2.017. diff --git a/src/runtime/x86-64-darwin-os.c b/src/runtime/x86-64-darwin-os.c index 86d4687..1050ade 100644 --- a/src/runtime/x86-64-darwin-os.c +++ b/src/runtime/x86-64-darwin-os.c @@ -249,8 +249,8 @@ void signal_emulation_wrapper(x86_thread_state64_t *thread_state, os_invalidate((os_vm_address_t)regs, sizeof(darwin_mcontext)); /* Trap to restore the signal context. */ - asm volatile ("mov %0, %%rax; mov %1, %%rbx; .quad 0xffffffffffff0b0f" - : : "r" (thread_state), "r" (float_state)); + asm volatile (".quad 0xffffffffffff0b0f" + : : "a" (thread_state), "b" (float_state)); } #if defined DUMP_CONTEXT diff --git a/src/runtime/x86-darwin-os.c b/src/runtime/x86-darwin-os.c index debc8cf..f10d071 100644 --- a/src/runtime/x86-darwin-os.c +++ b/src/runtime/x86-darwin-os.c @@ -273,8 +273,8 @@ void signal_emulation_wrapper(x86_thread_state32_t *thread_state, os_invalidate((os_vm_address_t)regs, sizeof(mcontext_t)); /* Trap to restore the signal context. */ - asm volatile ("movl %0, %%eax; movl %1, %%ebx; .long 0xffff0b0f" - : : "r" (thread_state), "r" (float_state)); + asm volatile (".long 0xffff0b0f" + : : "a" (thread_state), "b" (float_state)); } /* Convenience wrapper for the above */ -- 1.7.10.4