| 503 | } |
| 504 | |
| 505 | void StackWalker::checkFault() { |
| 506 | // Search for a crash protection context located on the current thread stack. |
| 507 | // Since one thread may use multiple contexts because of simultaneous profiling engines, |
| 508 | // we need to walk through all of them and find the nearest one (i.e. the most recent). |
| 509 | jmp_buf* nearest_ctx = NULL; |
| 510 | uintptr_t stack_distance = 32768; // maximum allowed stack distance |
| 511 | const uintptr_t current_sp = (uintptr_t)&nearest_ctx; |
| 512 | |
| 513 | for (int i = 0; i < CONCURRENCY_LEVEL; i++) { |
| 514 | jmp_buf* ctx = crash_protection_ctx[i]; |
| 515 | if ((uintptr_t)ctx - current_sp < stack_distance) { |
| 516 | nearest_ctx = ctx; |
| 517 | stack_distance = (uintptr_t)ctx - current_sp; |
| 518 | } |
| 519 | } |
| 520 | |
| 521 | if (nearest_ctx != NULL) { |
| 522 | longjmp(*nearest_ctx, 1); |
| 523 | } |
| 524 | } |
nothing calls this directly
no outgoing calls
no test coverage detected