summaryrefslogtreecommitdiff
path: root/ipc
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2011-03-14 02:14:46 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2011-03-14 02:14:46 +0100
commitd96ea910f11eeaf09d1a7d0afbfd43b0b3a3b056 (patch)
tree872e2aa54e34bf8b7e437753a41791ae27b4a97e /ipc
parent1b2aae815f6e4d7a14c7ebaab506d71ff9b50af4 (diff)
Also warn about mach_port_destroy on invalid ports
* ipc/mach_port.c (mach_port_destroy): Warn (and possibly call debugger) when ipc_right_lookup_write didn't find the port name.
Diffstat (limited to 'ipc')
-rw-r--r--ipc/mach_port.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/ipc/mach_port.c b/ipc/mach_port.c
index d902e22..122d5d9 100644
--- a/ipc/mach_port.c
+++ b/ipc/mach_port.c
@@ -552,6 +552,8 @@ mach_port_allocate(space, right, namep)
* KERN_INVALID_NAME The name doesn't denote a right.
*/
+static volatile int mach_port_deallocate_debug = 0;
+
kern_return_t
mach_port_destroy(
ipc_space_t space,
@@ -564,8 +566,14 @@ mach_port_destroy(
return KERN_INVALID_TASK;
kr = ipc_right_lookup_write(space, name, &entry);
- if (kr != KERN_SUCCESS)
+ if (kr != KERN_SUCCESS) {
+ if (name != MACH_PORT_NULL && name != MACH_PORT_DEAD) {
+ printf("task %p destroying an invalid port %u, most probably a bug.\n", current_task(), name);
+ if (mach_port_deallocate_debug)
+ SoftDebugger("mach_port_deallocate");
+ }
return kr;
+ }
/* space is write-locked and active */
kr = ipc_right_destroy(space, name, entry); /* unlocks space */
@@ -590,7 +598,6 @@ mach_port_destroy(
* KERN_INVALID_RIGHT The right isn't correct.
*/
-static volatile int mach_port_deallocate_debug = 0;
kern_return_t
mach_port_deallocate(
ipc_space_t space,