| 259 | // create some stack frames to inspect from CauseSegfault |
| 260 | #ifndef _WIN32 |
| 261 | __attribute__ ((noinline)) |
| 262 | #else |
| 263 | __declspec(noinline) |
| 264 | #endif |
| 265 | void segfault_stack_frame_1() |
| 266 | { |
| 267 | // DDOPSON-2013-04-16 using the address "1" instead of "0" prevents a nasty compiler over-optimization |
| 268 | // When using "0", the compiler will over-optimize (unless using -O0) and generate a UD2 instruction |
| 269 | // UD2 is x86 for "Invalid Instruction" ... (yeah, they have a valid code that means invalid) |
| 270 | // Long story short, we don't get our SIGSEGV. Which means no pretty demo of stacktraces. |
| 271 | // Instead, you see "Illegal Instruction: 4" on the console and the program stops. |
| 272 | |
| 273 | int *foo = (int*)1; |
| 274 | fprintf(stderr, "NodeSegfaultHandlerNative: about to dereference NULL (will cause a SIGSEGV)\n"); |
| 275 | *foo = 78; // trigger a SIGSEGV |
| 276 | |
| 277 | } |
| 278 | |
| 279 | #ifndef _WIN32 |
| 280 | __attribute__ ((noinline)) |
nothing calls this directly
no outgoing calls
no test coverage detected