Loader: a trapped unimplemented import goes into the crash log #245

Manually merged
github merged 1 commit from gh-pr/245/head into gh-pr/245/base 2026-11-26 03:56:22 +00:00
Owner

@⁠Dufftwt on GitHub · 2026-11-24 01:45 UTC · original
Dufftwt:fix/import-trap-in-crash-log → main · +42 −4 · 1 files · 1 commits · merged 2026-11-24 07:58 UTC

What's wrong

When the title calls an import that nothing implements, the default --unimplemented trap policy:

  1. logs it with tracing;
  2. prints VIctory: unimplemented import <dll>!<symbol> called;
  3. breaks into a debugger if one is attached;
  4. calls std::process::abort().

On Windows, abort() is a fast fail (__fastfail). It ends the process without running the vectored handler, the unhandled-exception filter or the panic hook, and those are the only things that append to crashes.log. So this crash, the most common one during bring-up, leaves nothing in crashes.log: not the import's name, and not the title's last debug lines that every other crash report carries. The README says every crash is appended there, and once the console window is gone, the log is all a reporter has.

What the fix does

The trap now reports through log_crash (in crash.rs), the function GPU failures already use, instead of a bare eprintln!. log_crash:

  • prints the same VIctory: unimplemented import <dll>!<symbol> called line to the console, as before;
  • appends it to crashes.log;
  • adds the title's last debug output, as other crash reports do.

The debugger break and the abort() are unchanged.

How it behaves after the fix

A title that calls a missing import still stops at once, with the same console line. crashes.log now also has an entry, VIctory: unimplemented import probe.dll!Missing called, followed by the title's last lines. A pasted log then says which API needs implementing.

Tests

a_trapped_import_is_in_the_crash_log reruns the test binary as a child process, using the same pattern as threads::tests::exit_ends_the_other_threads_first. The child sets up a crash log in a temp folder and calls a trapping stub for probe.dll!Missing. The parent then checks two things: the child failed, and the log names the import.

I ran cargo test --workspace on GitHub's windows-latest with Rust 1.98.1 from rust-toolchain.toml:

  • This PR: everything passes. victory-loader has 20 passed, the other crates have 0 failed.
  • The new test alone on main: it fails because the crash log is empty (crash log: ""). The child aborted without writing it.
  • I ran with --test-threads=1. With 4 threads, the shader crate's GPU tests sometimes crash on that runner (STATUS_ACCESS_VIOLATION), on unmodified main as well.

Not tested: a real title hitting a missing import.

**@⁠Dufftwt** on GitHub · 2026-11-24 01:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/245) `Dufftwt:fix/import-trap-in-crash-log` → `main` · +42 −4 · 1 files · 1 commits · merged 2026-11-24 07:58 UTC ## What's wrong When the title calls an import that nothing implements, the default `--unimplemented trap` policy: 1. logs it with `tracing`; 2. prints `VIctory: unimplemented import <dll>!<symbol> called`; 3. breaks into a debugger if one is attached; 4. calls `std::process::abort()`. On Windows, `abort()` is a fast fail (`__fastfail`). It ends the process without running the vectored handler, the unhandled-exception filter or the panic hook, and those are the only things that append to `crashes.log`. So this crash, the most common one during bring-up, leaves **nothing** in `crashes.log`: not the import's name, and not the title's last debug lines that every other crash report carries. The README says every crash is appended there, and once the console window is gone, the log is all a reporter has. ## What the fix does The trap now reports through `log_crash` (in `crash.rs`), the function GPU failures already use, instead of a bare `eprintln!`. `log_crash`: - prints the same `VIctory: unimplemented import <dll>!<symbol> called` line to the console, as before; - appends it to `crashes.log`; - adds the title's last debug output, as other crash reports do. The debugger break and the `abort()` are unchanged. ## How it behaves after the fix A title that calls a missing import still stops at once, with the same console line. `crashes.log` now also has an entry, `VIctory: unimplemented import probe.dll!Missing called`, followed by the title's last lines. A pasted log then says which API needs implementing. ## Tests `a_trapped_import_is_in_the_crash_log` reruns the test binary as a child process, using the same pattern as `threads::tests::exit_ends_the_other_threads_first`. The child sets up a crash log in a temp folder and calls a trapping stub for `probe.dll!Missing`. The parent then checks two things: the child failed, and the log names the import. I ran `cargo test --workspace` on GitHub's `windows-latest` with Rust 1.98.1 from `rust-toolchain.toml`: - **This PR:** everything passes. `victory-loader` has 20 passed, the other crates have 0 failed. - **The new test alone on `main`:** it fails because the crash log is empty (`crash log: ""`). The child aborted without writing it. - I ran with `--test-threads=1`. With 4 threads, the shader crate's GPU tests sometimes crash on that runner (`STATUS_ACCESS_VIOLATION`), on unmodified `main` as well. **Not tested:** a real title hitting a missing import.
An unimplemented import with the default Trap policy printed its name
and aborted. abort() is a fast fail: it skips the exception handlers
and the panic hook, which are what append to crashes.log, so the most
common bring-up crash left nothing there, not even which import it was.

The trap now reports through log_crash, which prints the same line,
appends it to the crash log and adds the title's last debug output.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:56:19 +00:00
github manually merged commit 5f670bbfdb into gh-pr/245/base 2026-11-26 03:56:22 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-24 05:06 UTC · original

Thanks @⁠Dufftwt for logging the trapped import before aborting. I tested the open PR at head 5f670bbfdba199a7537124adaa7ef5b0871e352b with:

cargo test --locked -p victory-loader --lib a_trapped_import_is_in_the_crash_log -- --test-threads=1

Result: 1 passed, 0 failed (19 filtered out). The controlled child-process test triggers an unimplemented import trap and verifies the import name appears in the crash log before the process aborts. This tests the crash-report path with a synthetic child process; no title or game log was used.

Code: thunks.rs.

**@⁠jeremygold02** on GitHub · 2026-11-24 05:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/245#issuecomment-7122625180) Thanks @⁠Dufftwt for logging the trapped import before aborting. I tested the open PR at head `5f670bbfdba199a7537124adaa7ef5b0871e352b` with: ``` cargo test --locked -p victory-loader --lib a_trapped_import_is_in_the_crash_log -- --test-threads=1 ``` Result: 1 passed, 0 failed (19 filtered out). The controlled child-process test triggers an unimplemented import trap and verifies the import name appears in the crash log before the process aborts. This tests the crash-report path with a synthetic child process; no title or game log was used. Code: [thunks.rs](https://github.com/Marvisak/VIctory/blob/5f670bbfdba199a7537124adaa7ef5b0871e352b/crates/victory-loader/src/thunks.rs).
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!245
No description provided.