darwin: using pointers as port names is not guaranteed to work

Bug #1470996 reported by Aaron Carroll on 2015-07-02
This bug affects 3 people
Affects Status Importance Assigned to Milestone

Bug Description

The OSX/Darwin implementation allocates a named mach port (mach_port_allocate_name()) on which to receive thread exceptions. The name is specified as the address of a "struct exception_port_record" object. In general, valid port names are small integers, so this approach is not guaranteed to work. A more reliable approach is to let the system choose a port name by using mach_port_allocate().

Mapping the exception port/mach thread to the internal thread struct could be done with a simple hash table on the exception port name. Alternatively, there is a mechanism to attach a context (opaque pointer) to a receive right, such as an exception port:

  mach_port_set_context(ipc_space, port, context)
  mach_port_get_context(ipc_space, port, &context)

Stashing the struct thread pointer in the exception port context when registering for the exceptions would allow simple lookup when the exception is raised.

Cyrus Harmon (ch-launchpad) wrote :

Aaron, can you put together a patch with the mach_port_{s,g}et_context approach?

Changed in sbcl:
status: New → Confirmed
importance: Undecided → Medium
Stas Boukarev (stassats) wrote :

In 2fd854b3b20fc95db33012b04d20dc27bdac0f91

Changed in sbcl:
status: Confirmed → Fix Committed
Stas Boukarev (stassats) on 2016-09-30
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers