EXC_BREAKPOINT (SIGTRAP) and EXC_BAD_INSTRUCTION (SIGILL)
A trace trap or invalid CPU instruction interrupted the process, often because the process violated a requirement or timeout.
Overview
A trace trap gives an attached debugger the chance to interrupt the process at a specific point in its execution. On ARM processors, this appears as EXC_BREAKPOINT (SIGTRAP). On x86_64 processors, this appears as EXC_BAD_INSTRUCTION (SIGILL).
The Swift runtime uses trace traps for specific types of unrecoverable errors—see Addressing crashes from Swift runtime errors for information on those errors. Some lower-level libraries, such as Dispatch, trap the process with this exception upon encountering an unrecoverable error, and log additional information about the error in the Additional Diagnostic Information section of the crash report. See Diagnostic messages for information about those messages.
If you want to use the same technique in your own code for unrecoverable errors, call the fatalError(_:file:line:) function in Swift, or the __builtin_trap() function in C. These functions allow the system to generate a crash report with thread backtraces that show how you reached the unrecoverable error.
An illegal CPU instruction means the program’s executable contains an instruction that the processor doesn’t implement or can’t execute. For example, the following program tries to perform the CPU instruction 0x00000001, which isn’t a valid instruction on Apple silicon:
#include <stdint.h>
int main(int argc, char **argv) {
static const uint32_t sTest[] = {
0x00000001,
};
typedef void (*FuncPtr)(void);
FuncPtr f = (FuncPtr) sTest;
f();
return 0;
}