mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 12:59:58 -04:00
End fatal errors and a lost device with TerminateProcess instead of _Exit, which ran every library's detach.
dispatch.c fatal_end and vk_device.c lost_wait_exit ended with _Exit, which in the C runtime is ExitProcess: it stops the other threads wherever they are and then runs every library's DLL_PROCESS_DETACH on the ending thread (the audit's probes show the exe's TLS callback getting it after _Exit and not after TerminateProcess). That is the detach plat_exit already avoids, after NGX's faulted once at the end of a clean run. After a FATAL such a fault would enter the crash handler and replace code 70 or 72 with a crash report and code 71; after a device loss a driver detach that hangs would hold the process for good, since ExitProcess had stopped the watchdog too. The new platform plat_terminate ends the process with the code and nothing else (no exit hook, no stream flush: the failing paths have written their lines and flushed). fatal_end calls it after its existing log sync and flushes. lost_wait_exit tells its watchdog (spawned with a non-NULL argument) from the threads that stop there: after LOST_EXIT_MS the watchdog alone writes "vk: the end of the run did not finish in 10 s; ending it" through rt_log_sync's bounded trylocks, and the others end 2 s later only should the watchdog not have started. Exit codes stay 70 and 72. Not reproduced before the change (no detach fault on a fatal path has been seen). tests/fatal_exit_check.py (new: dispatch.c and the platform layer with a TLS callback; rt_fatal ends with 70, its FATAL line and no detach call, which it showed with _Exit; and statically, no _Exit in runtime outside the platform layer, and both ends call plat_terminate) and the compile checks pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -331,6 +331,10 @@ void plat_aligned_free(void *p);
|
||||
// ---- process
|
||||
_Noreturn void plat_exit(int code); // ends the process at once: other threads stop, no atexit handlers run
|
||||
extern void (*plat_exit_hook)(void); // called first by plat_exit when set (main.c: the queued log lines)
|
||||
// Ends the process at once with code, and nothing else: no exit hook, no stream flush, and no library's detach call
|
||||
// (ExitProcess and _Exit run every one). For the ends of a failed run (dispatch.c fatal_end, vk_device.c
|
||||
// lost_wait_exit), which have written their lines themselves and must not wait on a lock another thread holds.
|
||||
_Noreturn void plat_terminate(int code);
|
||||
int plat_setenv(const char *name, const char *value); // value NULL removes it; 1 on success
|
||||
uint32_t plat_process_id(void);
|
||||
// CPU time of the process since it started (user and kernel), and wall time since it started, in ns; 0 when unknown.
|
||||
|
||||
Reference in New Issue
Block a user