Description
STATUS_STACK_BUFFER_OVERRUN
isn't only used for stack cookie checks, but also __fastfail
, which is used by abort()
, making programs that abort exit with 0xc0000409. However, people generally aren't aware of that connection, as it's a Windows status code and searching for one of those yields pages and pages of articles with the quality of AI slop.
Take #141626 as an example: The linker crashed due to a call to abort()
, but it was initially misreported as "Link.exe overflowed it's stack." As we already emit special diagnostics if link.exe
fails with exit codes outside of the known range, we could also print a special diagnostic for that exit code - and since that code already queries the registry, i.e. accesses resources external to rustc, it could maybe also look at the WER event log entries and read the fast-fail code out of the event log entry to disambiguate __fastfail
from other error sources.
Current output
error: linking with `link.exe` failed: exit code: 0xc0000409
|
= note: <linker invocation>
= note: some arguments are omitted. use `--verbose` to show all linker arguments
= note:
note: `link.exe` returned an unexpected error
note: the Visual Studio build tools may need to be repaired using the Visual Studio installer
note: or a necessary component may be missing from the "C++ build tools" workload
Desired output
error: linking with `link.exe` failed: exit code: 0xc0000409
|
= note: <linker invocation>
= note: some arguments are omitted. use `--verbose` to show all linker arguments
= note:
note: `link.exe` returned an unexpected error
note: 0xc0000409 is `STATUS_STACK_BUFFER_OVERRUN`, which is used for abnormal program termination and does not necessarily indicate a stack buffer overrun.
note: the Visual Studio build tools may need to be repaired using the Visual Studio installer
note: or a necessary component may be missing from the "C++ build tools" workload
Rust Version
rustc 1.87.0 (17067e9ac 2025-05-09)
binary: rustc
commit-hash: 17067e9ac6d7ecb70e50f92c1944e545188d2359
commit-date: 2025-05-09
host: x86_64-pc-windows-msvc
release: 1.87.0
LLVM version: 20.1.1