From 6ec7813e91200fe94aecaeab87b360eeae421179 Mon Sep 17 00:00:00 2001 From: Andy Leiserson Date: Thu, 18 Jun 2026 13:32:43 -0700 Subject: [PATCH] test(cts): Improve diagnostics (#9695) --- cts_runner/src/main.rs | 65 ++++++++++++++++++++++++++++++++++++++++++ typos.toml | 3 ++ xtask/src/cts.rs | 4 ++- 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/cts_runner/src/main.rs b/cts_runner/src/main.rs index 81cbbe057..fd88062d4 100644 --- a/cts_runner/src/main.rs +++ b/cts_runner/src/main.rs @@ -174,8 +174,73 @@ impl deno_web::TimersPermission for Permissions { } } +/// On Windows, install an SEH filter that logs the exception code, so +/// unhandled-exception crashes from native code (driver bugs, WARP, D3D12) are +/// more visible in CI. (See for an +/// example.) +#[cfg(windows)] +fn install_unhandled_exception_filter() { + use core::ffi::c_void; + + #[repr(C)] + struct ExceptionRecord { + exception_code: u32, + exception_flags: u32, + exception_record: *mut ExceptionRecord, + exception_address: *mut c_void, + number_parameters: u32, + exception_information: [usize; 15], + } + + #[repr(C)] + struct ExceptionPointers { + exception_record: *mut ExceptionRecord, + context_record: *mut c_void, + } + + type FilterFn = unsafe extern "system" fn(*mut ExceptionPointers) -> i32; + + unsafe extern "system" { + fn SetUnhandledExceptionFilter(filter: Option) -> Option; + } + + unsafe extern "system" fn filter(info: *mut ExceptionPointers) -> i32 { + let (code, addr) = unsafe { + if info.is_null() || (*info).exception_record.is_null() { + (0u32, core::ptr::null_mut::()) + } else { + let r = &*(*info).exception_record; + (r.exception_code, r.exception_address) + } + }; + let name = match code { + 0x80000003 => "STATUS_BREAKPOINT", + 0xC0000005 => "STATUS_ACCESS_VIOLATION", + 0xC0000094 => "STATUS_INTEGER_DIVIDE_BY_ZERO", + 0xC00000FD => "STATUS_STACK_OVERFLOW", + 0xC0000374 => "STATUS_HEAP_CORRUPTION", + 0xC0000409 => "STATUS_STACK_BUFFER_OVERRUN", + 0xC0000602 => "STATUS_FAIL_FAST_EXCEPTION", + _ => "", + }; + eprintln!("cts_runner: unhandled SEH exception 0x{code:08x} ({name}) at {addr:p}"); + // EXCEPTION_CONTINUE_SEARCH: let the OS proceed with its default + // termination so the process exit code still reflects the fault. + 0 + } + + // SAFETY: passing a valid `extern "system"` function pointer. + unsafe { + SetUnhandledExceptionFilter(Some(filter)); + } +} + #[tokio::main(flavor = "current_thread")] async fn main() { + #[cfg(windows)] + { + install_unhandled_exception_filter(); + } env_logger::init(); unwrap_or_exit(run().await) } diff --git a/typos.toml b/typos.toml index 2fb655269..e687ea718 100644 --- a/typos.toml +++ b/typos.toml @@ -24,6 +24,9 @@ metalness = "metalness" # A DXC command line argument Fo = "Fo" +# Abbreviation of Structured Exception Handling +SEH = "SEH" + # Usernames Healthire = "Healthire" REASY = "REASY" diff --git a/xtask/src/cts.rs b/xtask/src/cts.rs index 41c159c64..de60b6c48 100644 --- a/xtask/src/cts.rs +++ b/xtask/src/cts.rs @@ -442,13 +442,15 @@ pub fn run_cts( println!("\n== Summary for {} ==", test.selector.to_string_lossy()); println!("{}", summary.trim()); } else { + log::info!("Running {}", test.selector.to_string_lossy()); print!("{}", stdout); eprint!("{}", stderr); } } else { + log::info!("Running {}", test.selector.to_string_lossy()); print!("{}", stdout); eprint!("{}", stderr); - bail!("CTS failed"); + bail!("CTS failed ({})", output.status); } } PrintOutputWhen::Always => {