A
Andrey Vul
In the following code, the dereferencing of NULL at line main+2
triggers a segfault, which calls handl(SEGV). Is the behavior
dereferencing of NULL in the SEGV handler undefined, implementation-
dependent, or standardized?
It looks like the OS doesn't want to tolerate double pagefaults or
nested fatal signals, and simply kills the offending process, which
lead me to reading ISO 9899:1999.
I couldn't find anything to do with nested terminate-or-core signals
in the spec. Could I get clarification on this?
Note: raise(u) instead of dereferencing NULL did not cause a crash.
code:
#include <stdio.h>
#include <signal.h>
sig_atomic_t dep;
void handl(int u) {
dep++;
write(1, &dep, sizeof dep);
*((char *)0) = 0;
}
int main() {
dep=0;
signal(SIGSEGV, handl);
*((char *)0) = 0;
return 0;
}
triggers a segfault, which calls handl(SEGV). Is the behavior
dereferencing of NULL in the SEGV handler undefined, implementation-
dependent, or standardized?
It looks like the OS doesn't want to tolerate double pagefaults or
nested fatal signals, and simply kills the offending process, which
lead me to reading ISO 9899:1999.
I couldn't find anything to do with nested terminate-or-core signals
in the spec. Could I get clarification on this?
Note: raise(u) instead of dereferencing NULL did not cause a crash.
code:
#include <stdio.h>
#include <signal.h>
sig_atomic_t dep;
void handl(int u) {
dep++;
write(1, &dep, sizeof dep);
*((char *)0) = 0;
}
int main() {
dep=0;
signal(SIGSEGV, handl);
*((char *)0) = 0;
return 0;
}