gencgc: More precise conservatism for pointers to boxed pages.
[sbcl.git] / src / runtime / x86-64-darwin-os.c
index 8a25e63..3c06b56 100644 (file)
@@ -325,9 +325,10 @@ catch_exception_raise(mach_port_t exception_port,
 
     os_vm_address_t addr;
 
-    struct thread *th = (struct thread*) exception_port;
+    struct thread *th;
 
     FSHOW((stderr,"/entering catch_exception_raise with exception: %d\n", exception));
+    th = *(struct thread**)exception_port;
 
     switch (exception) {
 
@@ -346,8 +347,6 @@ catch_exception_raise(mach_port_t exception_port,
                                (thread_state_t)&exception_state,
                                &exception_state_count);
         addr = (void*)exception_state.faultvaddr;
-
-
         /* note the os_context hackery here.  When the signal handler returns,
          * it won't go back to what it was doing ... */
         if(addr >= CONTROL_STACK_GUARD_PAGE(th) &&
@@ -575,6 +574,9 @@ catch_exception_raise(mach_port_t exception_port,
         ret = KERN_INVALID_RIGHT;
     }
 
+    if (current_mach_task == MACH_PORT_NULL)
+        current_mach_task = mach_task_self();
+
     dealloc_ret = mach_port_deallocate (current_mach_task, thread);
     if (dealloc_ret) {
       lose("mach_port_deallocate (thread) failed with return_code %d\n", dealloc_ret);