mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-16 09:39:58 -04:00
A stack overflow leaves the faulting thread only a guard page's worth of stack for the handler, and the crash report needs more: main.c crash_handler's rt_log buffers are 2 KiB each, it walks the frames, and while the boot builds pipelines its first call writes a file (plat_file_write's frame is about 4 KiB). Nothing in the runtime set a stack guarantee, so the report faulted again; the verifier's probe ended with 0xC0000005 and no line once the report's first call was the file write. The launcher starts the game with stderr on DEVNULL, so raw_note's stderr line was all there was, and nobody saw it. The new platform plat_stack_guarantee calls SetThreadStackGuarantee with PLAT_STACK_GUARANTEE (32 KiB) and runs at the start of every thread win32.c thread_main starts, in fiber_start (a guest fiber's stack is its own and the guarantee belongs to the running fiber), and on the main thread in main. Each thread and fiber commits that much more of its stack. Linux's crash handling already runs on its signal stack (linux.c alt_stack), so it is empty there. Reproduced before the change by the new tests/crash_stack_check.py: a plat_thread_spawn thread and a plat_fiber_new fiber recurse until their stacks run out, and the handler writes a file and three 2 KiB log lines. Without the guarantee both ended with 0xC0000005 and no line; with it both write every line and end with 71. thread_end_check, fatal_exit_check and the compile checks pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>