Repository: astral-sh/uv
File: crates/uv/src/windows_exception.rs (Rust)

Code before:
    exception_info: *const EXCEPTION_POINTERS,
) -> i32 {
    // TODO: Really we should not be using eprintln here because Stderr is not async-signal-safe.
    // Probably we should be calling the console APIs directly.
    eprintln!("error: unhandled exception in uv, please report a bug:");
    let mut context = None;
    // SAFETY: Pointer comes from the OS
    if let Some(info) = unsafe { exception_info.as_ref() } {
        // SAFETY: Pointer comes from the OS
        if let Some(exc) = unsafe { info.ExceptionRecord.as_ref() } {
            eprintln!(
                "code {:#X} at address {:?}",
                exc.ExceptionCode.0, exc.ExceptionAddress
            );
            match exc.ExceptionCode {
                Foundation::EXCEPTION_ACCESS_VIOLATION => {
                    display_exception_info("EXCEPTION_ACCESS_VIOLATION", &exc.ExceptionInformation);
                }
                Foundation::EXCEPTION_IN_PAGE_ERROR => {
                    display_exception_info("EXCEPTION_IN_PAGE_ERROR", &exc.ExceptionInformation);
                }
                Foundation::EXCEPTION_ILLEGAL_INSTRUCTION => {
                    eprintln!("EXCEPTION_ILLEGAL_INSTRUCTION");
                }
                Foundation::EXCEPTION_STACK_OVERFLOW => {
                    eprintln!("EXCEPTION_STACK_OVEFLOW");
                }
                _ => {}
            }
        } else {
            eprintln!("(ExceptionRecord is NULL)");
        }
        // SAFETY: Pointer comes from the OS
        context = unsafe { info.ContextRecord.as_ref() };
    } else {
        eprintln!("(ExceptionInfo is NULL)");
    }
    let backtrace = std::backtrace::Backtrace::capture();
    if backtrace.status() == std::backtrace::BacktraceStatus::Disabled {
        eprintln!("note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace");
    } else {
        if let Some(context) = context {
            dump_regs(context);
        }
        eprintln!("stack backtrace:\n{backtrace:#}");
    }
    EXCEPTION_CONTINUE_SEARCH
}

/// Set up our handler for unhandled exceptions.
pub(crate) fn setup() {

Review comment (bug):
```suggestion
                    eprintln!("EXCEPTION_STACK_OVERFLOW");
```

Fixes failing `typo` job in CI

Code after:
}

unsafe extern "system" fn unhandled_exception_filter(
    exception_info: *const EXCEPTION_POINTERS,
) -> i32 {
    // TODO: Really we should not be using eprintln here because Stderr is not async-signal-safe.
    // Probably we should be calling the console APIs directly.
    eprintln!("error: unhandled exception in uv, please report a bug:");
    let mut context = None;
    // SAFETY: Pointer comes from the OS
    if let Some(info) = unsafe { exception_info.as_ref() } {
        // SAFETY: Pointer comes from the OS
        if let Some(exc) = unsafe { info.ExceptionRecord.as_ref() } {
            eprintln!(
                "code {:#X} at address {:?}",
                exc.ExceptionCode.0, exc.ExceptionAddress
            );
            match exc.ExceptionCode {
                Foundation::EXCEPTION_ACCESS_VIOLATION => {
                    display_exception_info("EXCEPTION_ACCESS_VIOLATION", &exc.ExceptionInformation);
                }
                Foundation::EXCEPTION_IN_PAGE_ERROR => {
                    display_exception_info("EXCEPTION_IN_PAGE_ERROR", &exc.ExceptionInformation);
                }
                Foundation::EXCEPTION_ILLEGAL_INSTRUCTION => {
                    eprintln!("EXCEPTION_ILLEGAL_INSTRUCTION");
                }
                Foundation::EXCEPTION_STACK_OVERFLOW => {
                    eprintln!("EXCEPTION_STACK_OVERFLOW");
                }
                _ => {}
            }
        } else {
            eprintln!("(ExceptionRecord is NULL)");
        }
        // SAFETY: Pointer comes from the OS
        context = unsafe { info.ContextRecord.as_ref() };
    } else {
        eprintln!("(ExceptionInfo is NULL)");
    }
    let backtrace = std::backtrace::Backtrace::capture();
    if backtrace.status() == std::backtrace::BacktraceStatus::Disabled {
        eprintln!("note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace");
    } else {
        if let Some(context) = context {
            dump_regs(context);
        }
        eprintln!("stack backtrace:\n{backtrace:#}");
    }
    EXCEPTION_CONTINUE_SEARCH
}