Native crash capture on Windows, and startup steps in crash reports (#1215)
A crash inside a graphics driver left only "an unclean exit between commands": no backtrace, no module, no hint that it was at startup. - The crash journal now keeps the startup step the app is in (window, graphics instance, surface, adapter request, adapter chosen, device creation, renderer and viewport shader compiles, surface configure, first frame and its present, running) and the renderer as soon as the adapter is picked. egui-wgpu tells the app about its steps through a small hook. An unclean exit before the first frame names the step. - Windows: an unhandled-exception filter (src/native_crash.rs, the one Windows-only module allowed unsafe) writes the exception code, the faulting module and offset, and a minidump next to the journal; the next start puts them into the report. - The Windows CI job runs a child that faults on purpose and checks the report. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0ddd660089
commit
d20b0fab65
15 files changed
+703
-30
No files matched your search
@@ -20,6 +20,24 @@ fn child() {
|
||||
};
|
||||
let fresh = install(PathBuf::from(dir), build());
|
||||
println!("FRESH {}", serde_json::to_string(&fresh).unwrap());
|
||||
// Dying while starting up, before any command: in a graphics driver, with or without what
|
||||
// a native crash handler caught.
|
||||
if mode == "startup" || mode == "native" {
|
||||
phase("window");
|
||||
phase("adapter request");
|
||||
set_environment("Renderer: Vulkan Test GPU (driver 1.2.3)");
|
||||
phase("device creation");
|
||||
if mode == "native" {
|
||||
let (info, dump) = native_paths().unwrap();
|
||||
fs::write(
|
||||
info,
|
||||
r#"{"code":"0xC0000005","name":"EXCEPTION_ACCESS_VIOLATION","detail":"read of 0x0000000000000010","address":"0x00007FFB12345678","module":"C:\\Windows\\System32\\DriverStore\\igvk64.dll","offset":"0x64EA72","thread":4242}"#,
|
||||
)
|
||||
.unwrap();
|
||||
fs::write(dump, b"MDMP fake").unwrap();
|
||||
}
|
||||
std::process::abort();
|
||||
}
|
||||
set_environment("Renderer: test");
|
||||
let mut s = Session { crash_journal: true, ..Default::default() };
|
||||
s.execute("solid.box", &json!({"length": 10, "width": 20, "height": 30})).unwrap();
|
||||
@@ -187,6 +205,69 @@ fn render_settings_survive_unclean_exit_and_journal_replay() {
|
||||
let _ = fs::remove_dir_all(&d);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_crash_while_starting_up_names_the_step_and_the_renderer() {
|
||||
let d = fresh_dir("startup");
|
||||
let (_, ok) = run_child(&d, "startup");
|
||||
assert!(!ok, "the child aborted");
|
||||
let (_, ok) = run_child(&d, "none");
|
||||
assert!(ok);
|
||||
let (s, v) = only_report(&d);
|
||||
assert_eq!(s.kind, "unclean_exit");
|
||||
assert!(s.message.contains("during startup (device creation"), "{}", s.message);
|
||||
assert_eq!(v["location"], "unclean exit during startup: device creation");
|
||||
assert_eq!(v["startup_phase"]["step"], "device creation");
|
||||
assert_eq!(v["system"]["environment"], "Renderer: Vulkan Test GPU (driver 1.2.3)", "{v}");
|
||||
let _ = fs::remove_dir_all(&d);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_native_crash_is_reported_with_the_module_the_step_and_the_minidump() {
|
||||
let d = fresh_dir("native");
|
||||
let (_, ok) = run_child(&d, "native");
|
||||
assert!(!ok, "the child aborted");
|
||||
let (_, ok) = run_child(&d, "none");
|
||||
assert!(ok);
|
||||
let (s, v) = only_report(&d);
|
||||
assert_eq!(s.kind, "unclean_exit");
|
||||
assert!(s.message.contains("EXCEPTION_ACCESS_VIOLATION (0xC0000005) in igvk64.dll+0x64EA72 during startup (device creation"), "{}", s.message);
|
||||
assert_eq!(v["location"], "native exception in igvk64.dll+0x64EA72");
|
||||
assert_eq!(v["native"]["thread"], 4242);
|
||||
let bt: Vec<&str> = v["backtrace"].as_array().unwrap().iter().map(|f| f.as_str().unwrap()).collect();
|
||||
assert_eq!(bt[0], "0xC0000005 EXCEPTION_ACCESS_VIOLATION (read of 0x0000000000000010)");
|
||||
assert!(bt[1].contains("igvk64.dll+0x64EA72"), "{bt:?}");
|
||||
assert_eq!(fs::read(v["minidump_path"].as_str().unwrap()).unwrap(), b"MDMP fake");
|
||||
assert_eq!(v["files"]["minidump"], "minidump.dmp");
|
||||
// Nothing is left behind next to the journals.
|
||||
let left: Vec<_> = fs::read_dir(d.join("sessions")).unwrap().flatten().map(|e| e.file_name()).collect();
|
||||
assert!(left.iter().all(|n| n.to_string_lossy().ends_with(".jsonl")), "{left:?}");
|
||||
// The same crash again is counted, not written again.
|
||||
let _ = run_child(&d, "native");
|
||||
let _ = run_child(&d, "none");
|
||||
let (s, _) = only_report(&d);
|
||||
assert_eq!(s.count, 2);
|
||||
let _ = fs::remove_dir_all(&d);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn startup_steps_survive_a_rebase_and_running_ends_startup() {
|
||||
let d = fresh_dir("rebase");
|
||||
fs::create_dir_all(d.join("sessions")).unwrap();
|
||||
let mut j = Journal::open(&d, &build(), now());
|
||||
j.phase = Some(json!({"phase": "first frame", "ms": 5}).to_string());
|
||||
j.environment = Some(json!({"environment": "Renderer: X"}).to_string());
|
||||
j.rebase(&json!("new"), 1);
|
||||
let r = read_journal(j.path.as_ref().unwrap());
|
||||
assert_eq!(r.phase, Some(("first frame".to_string(), 5)));
|
||||
assert_eq!(r.environment.as_deref(), Some("Renderer: X"));
|
||||
j.write(&json!({"phase": RUNNING, "ms": 9}).to_string());
|
||||
let r = read_journal(j.path.as_ref().unwrap());
|
||||
assert_eq!(r.phase, Some((RUNNING.to_string(), 9)));
|
||||
assert!(from_journal(r).fields.get("startup_phase").is_none(), "a running app is past startup");
|
||||
drop(j);
|
||||
let _ = fs::remove_dir_all(&d);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_journal_reads_back_its_base_commands_and_the_one_in_flight() {
|
||||
let d = fresh_dir("journal");
|
||||
|
||||
Reference in new issue
Block a user