How to programmatically trigger a SIGSEGV on macos?
I have:
int i = 0;
int * ip = &i;
while (true) {
*ip++ = 0;
}
However, on Macos, this causes "EXC_BAD_ACCESS", not "SIGSEGV".
How to programmatically trigger a SIGSEGV on macos?
I have:
int i = 0;
int * ip = &i;
while (true) {
*ip++ = 0;
}
However, on Macos, this causes "EXC_BAD_ACCESS", not "SIGSEGV".
Copyright © 2021 Jogjafile Inc.
Here's a little C program that (on my Mac, anyway) demonstrates that it is in fact
SIGSEGVthat is being raised, regardless of what MacOS is calling it. This program installs a signal handler forSIGSEGV, then invokes some undefined behavior to provoke a segmentation fault into occurring, in order to see if the handler does in fact get executed.On my machine, I see this when I run the program:
Here's the program's source:
Note that if I comment out the
sigaction()call in the program, then running the program gives this output:... which is likely more in line with the output you were expecting.