From: Paul Khuong Date: Sat, 20 Apr 2013 11:43:00 +0000 (+0200) Subject: Fix the build on OS X 10.8.0 X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=0562f2b641c71b8461f9aac4a354ff4b341961fe;p=sbcl.git Fix the build on OS X 10.8.0 It seems our exception handler can be called before it's fully set up. Handle that case without potentially leaking too many ports. Reported by Gabriel Dos Reis on sbcl-devel. --- diff --git a/NEWS b/NEWS index a4a0305..c2cf5f2 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ ;;;; -*- coding: utf-8; fill-column: 78 -*- changes relative to sbcl-1.1.6 + * bug fix: our mach exception handler can seemingly called very early in + the program execution process on OS X 10.8.0. Try and handle that case + robustly, without potentially leaking mach ports too much. * enhancement: TRACE :PRINT-ALL handles multiple-valued forms. (lp#457053) * bug fix: :allocation slot option works for condition slots diff --git a/src/runtime/x86-64-darwin-os.c b/src/runtime/x86-64-darwin-os.c index 6378d7b..3c06b56 100644 --- a/src/runtime/x86-64-darwin-os.c +++ b/src/runtime/x86-64-darwin-os.c @@ -574,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); diff --git a/src/runtime/x86-darwin-os.c b/src/runtime/x86-darwin-os.c index 8489322..bf127b6 100644 --- a/src/runtime/x86-darwin-os.c +++ b/src/runtime/x86-darwin-os.c @@ -504,6 +504,9 @@ catch_exception_raise(mach_port_t exception_port, call_handler_on_thread(thread, &thread_state, signal, &siginfo, handler); } + 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);