From 2c5a710f4da100f8aa9c7262fa76395f73ee4307 Mon Sep 17 00:00:00 2001 From: Cyrus Harmon Date: Tue, 8 Mar 2011 15:33:44 +0000 Subject: [PATCH] 1.0.46.31: clean up mach port deallocation on x86 * don't deallocate the exception_port port and check the return values from deallocating the thread and task ports --- NEWS | 3 +++ src/runtime/x86-darwin-os.c | 14 ++++++++++---- version.lisp-expr | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 7d57df6..741ba8a 100644 --- 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) diff --git a/src/runtime/x86-darwin-os.c b/src/runtime/x86-darwin-os.c index 6205445..debc8cf 100644 --- a/src/runtime/x86-darwin-os.c +++ b/src/runtime/x86-darwin-os.c @@ -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; } diff --git a/version.lisp-expr b/version.lisp-expr index ba612df..a6f5c7f 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -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" -- 1.7.10.4