1.0.46.31: clean up mach port deallocation on x86
authorCyrus Harmon <ch-sbcl@bobobeach.com>
Tue, 8 Mar 2011 15:33:44 +0000 (15:33 +0000)
committerCyrus Harmon <ch-sbcl@bobobeach.com>
Tue, 8 Mar 2011 15:33:44 +0000 (15:33 +0000)
 * don't deallocate the exception_port port and check the return
   values from deallocating the thread and task ports

NEWS
src/runtime/x86-darwin-os.c
version.lisp-expr

diff --git a/NEWS b/NEWS
index 7d57df6..741ba8a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
 ;;;; -*- coding: utf-8; fill-column: 78 -*-
 changes relative to sbcl-1.0.46:
+  * bug fix: fix mach port rights leaks in mach exception handling code on
+    darwin/x86 and /x86-64. (thanks to Willem Oudshoorn for motivation and the
+    initial patch)
   * enhancement: --script muffles style-warnings and compiler notes. (lp#677779)
   * enhancement: redefinition warnings for macros from different files. (lp#434657)
   * enhancement: better MACHINE-VERSION on Darwin x86 and x86-64. (lp#668332)
index 6205445..debc8cf 100644 (file)
@@ -398,7 +398,7 @@ catch_exception_raise(mach_port_t exception_port,
     int signal = 0;
     void (*handler)(int, siginfo_t *, void *) = NULL;
     siginfo_t siginfo;
-    kern_return_t ret;
+    kern_return_t ret, dealloc_ret;
 
     /* Get state and info */
     state_count = x86_THREAD_STATE32_COUNT;
@@ -496,9 +496,15 @@ catch_exception_raise(mach_port_t exception_port,
       call_handler_on_thread(thread, &thread_state, signal, &siginfo, handler);
     }
 
-    mach_port_deallocate (current_mach_task, exception_port);
-    mach_port_deallocate (current_mach_task, thread);
-    mach_port_deallocate (current_mach_task, task);
+    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);
+    }
+
+    dealloc_ret = mach_port_deallocate (current_mach_task, task);
+    if (dealloc_ret) {
+      lose("mach_port_deallocate (task) failed with return_code %d\n", dealloc_ret);
+    }
 
     return ret;
 }
index ba612df..a6f5c7f 100644 (file)
@@ -20,4 +20,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.46.30"
+"1.0.46.31"