MPS issue job004069

TitlemacOS thread registration guard is ineffective and unnecessary
Assigned userGareth Rees
DescriptionThe function ProtThreadRegister in protxc.c arranges to deliver EXC_BAD_ACCESS exceptions to protExcPort so that they can be handled by the MPS. Some effort is made to avoid doing this twice for the "main" thread (the one that first creates an arena and so calls ProtSetup).

This is ineffective (because a thread can be registered with multiple arenas, and on the second and subsequent registrations the exception swapping would be repeated for that thread) and also unnecessary (because nothing goes wrong when the guard is removed: swapping the exception port is idempotent).
AnalysisIt looks as though the guard was necessary in a previous version of the code, when an attempt was made to remember the old exception port for each thread and pass unrecognized exceptions through to that port. But the current version of the code assumes that this is unnecessary (see .assume.only-port) and so we can simplify it by removing the guard.
How foundinspection
Created byGareth Rees
Created on2018-06-15 12:36:26
Last modified byGareth Rees
Last modified on2018-06-15 12:44:51
History2018-06-15 GDR Created.


Change Effect Date User Description
193828 closed 2018-06-15 12:44:51 Gareth Rees It's safe to register a thread multiple times on macOS, so there is no need for the guard.