SIGABRT handler: HIP runtime crashes in Monitor::tryLock during process exit because its atexit cleanup runs after threads are torn down. We catch the resulting abort and force a clean exit since all useful work is already done. Uses `exit_group` syscall directly for reliable process termination.
(_sig: libc::c_int)
| 26 | /// |
| 27 | /// Uses `exit_group` syscall directly for reliable process termination. |
| 28 | extern "C" fn hip_sigabrt_handler(_sig: libc::c_int) { |
| 29 | if HIP_INITIALIZED.load(Ordering::Relaxed) { |
| 30 | unsafe { libc::syscall(libc::SYS_exit_group, 0); } |
| 31 | } |
| 32 | // Not HIP-related — re-raise with default handler |
| 33 | unsafe { |
| 34 | libc::signal(libc::SIGABRT, libc::SIG_DFL); |
| 35 | libc::raise(libc::SIGABRT); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | /// atexit handler: terminates process before HIP's broken atexit cleanup runs. |
| 40 | /// Registered after HIP init, so runs before HIP's handler (LIFO order). |