Add diagnostic explaining STATUS_STACK_BUFFER_OVERRUN not only being

used for stack buffer overruns if link.exe exits with that exit code

`STATUS_STACK_BUFFER_OVERRUN` is also used for fast abnormal program
termination, e.g. by abort(). Emit a special diagnostic to let people
know that this most likely doesn't indicate a stack buffer overrun.
This commit is contained in:
George Tokmaji
2025-05-31 21:18:41 +02:00
parent 2fd855fbfc
commit b60f75c926
3 changed files with 16 additions and 0 deletions

View File

@@ -880,6 +880,14 @@ fn link_natively(
windows_registry::find_tool(&sess.target.arch, "link.exe").is_some();
sess.dcx().emit_note(errors::LinkExeUnexpectedError);
// STATUS_STACK_BUFFER_OVERRUN is also used for fast abnormal program termination, e.g. abort().
// Emit a special diagnostic to let people know that this most likely doesn't indicate a stack buffer overrun.
const STATUS_STACK_BUFFER_OVERRUN: i32 = 0xc0000409u32 as _;
if code == STATUS_STACK_BUFFER_OVERRUN {
sess.dcx().emit_note(errors::LinkExeStatusStackBufferOverrun);
}
if is_vs_installed && has_linker {
// the linker is broken
sess.dcx().emit_note(errors::RepairVSBuildTools);

View File

@@ -550,6 +550,11 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for LinkingFailed<'_> {
#[diag(codegen_ssa_link_exe_unexpected_error)]
pub(crate) struct LinkExeUnexpectedError;
#[derive(Diagnostic)]
#[diag(codegen_ssa_link_exe_status_stack_buffer_overrun)]
#[note]
pub(crate) struct LinkExeStatusStackBufferOverrun;
#[derive(Diagnostic)]
#[diag(codegen_ssa_repair_vs_build_tools)]
pub(crate) struct RepairVSBuildTools;