How is a Crash implemented? Mach and POSIX Signals

The KERN_INVALID_ADDRESS return code indicates an unsafe memory access; outside the virtual address space of the process. This is a classic attack vector for Level 9 system compromise, so crashing really is the best outcome here. 

The virtual memory subsystem vm ultimately invokes the exception handling subsystem, which transforms the kernel exception into a higher-level exception that terminates the process.

These systems are all part of

Mach, the low-level microkernel that powers XNU. Mach manages virtual memory, inter-process communication, thread scheduling, and exception handling.

This high-level exception takes the form of a SIGSEV POSIX signal — a notification sent to the offending thread to kill its parent process. 
We can see this mapping from KERN_INVALID_ADDRESS to SIGSEV in xnu/bsd/uxkern/ux_exception.c:

SIGSEV is a segmentation fault, which is a fancy word for a dangerous memory access violation.  

THE CRASH IS A LIE

An exceptional deep dive

Jacob’s Tech Tavern