Skip to content

startup: decode the MSVC C++ exception record into a sanitized summary - #1801

Closed
tedin7 wants to merge 2 commits into
R0Y00:mainfrom
tedin7:x2w-frontier-throwinfo
Closed

tedin7 wants to merge 2 commits into
R0Y00:mainfrom
tedin7:x2w-frontier-throwinfo

Conversation

@tedin7

@tedin7 tedin7 commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Refs #1758. This is the decoder only: it is not wired into tools/startup/debug_launch.py (untouched, so it does not collide with #1408 or the other open PRs that edit that file). The follow-up that calls it at the first-chance stop is a separate change.

What it does

tools/startup/msvc_throw_info.py turns a 0xE06D7363 exception record into a sanitized summary. #1758 needs the thrown HRESULT of the BVH builder, whose throw info says the catchable type is the built-in long (.J), without putting addresses or names from the title in a public comment.

decode_throw(exception_code, params, read_mem) follows the public MSVC x64 layout (ehdata.h): params[0] magic, [1] thrown object, [2] _ThrowInfo, [3] image base; _ThrowInfo → RVA of _CatchableTypeArray → RVAs of _CatchableType → RVA of type_info, whose decorated name is at offset 16. read_mem(address, size) -> bytes | None is the only access to memory, so the core has no Win32 dependency: in debug_launch.py it would be the existing read.

The record it returns has:

  • status: ok, not_msvc_exception, missing_parameters (fewer than four, so no image base), bad_magic, no_throw_info, unreadable, bad_throw_info, too_many_types (cap of 16, a safety limit).
  • types: one entry per catchable type. Built-in scalars and a short list of public library classes (std::runtime_error, _com_error, ...) are named; any other class is other, so a class of the title never appears.
  • value, only when the first catchable type is a 32-bit scalar (.J, .H, .I, .K) of size 4: the HRESULT as a public name (E_INVALIDARG, E_OUTOFMEMORY, DXGI_ERROR_DEVICE_REMOVED, DXGI_ERROR_DEVICE_HUNG, D3D12_ERROR_*, common HRESULT_FROM_WIN32(...)), or HRESULT(0x........), with its facility category (win32, dxgi, d3d12, other). A positive number above 65535 is not reported.
  • Never an address, a path, a name from the title or a number over 32 bits. describe(record) gives a one-line form made of those fields only.

Test

tests/startup_msvc_throw_info_check.py builds synthetic exception records in a fake address space (no title data) and checks 83 cases: ten HRESULTs through .J (E_INVALIDARG, E_OUTOFMEMORY, DXGI_ERROR_DEVICE_REMOVED, a generic one, ...), .H and .I, another exception code, wrong magic, three parameters, null throw info and image base, a read that fails at each of the four steps (and a callback that returns short data or raises), an RVA beyond the readable range and one that overflows 64 bits, a negative count, 16 and 17 catchable types, a zero RVA, runtime_error, _com_error, a class of the title, a long of the wrong size, malformed names, a name that ends before unmapped memory, and a sweep that no record contains an address, a path, long hex or a number over 32 bits.

It is registered in CMakeLists.txt after startup_triage_run and in the Python check list of .github/workflows/windows.yml next to startup_triage_run_check.py.

Results (Linux, local)

Not run, not established

  • No Windows run and no real exception record: the layout is the public one as documented, and the test builds records from it, so a difference in a real record would not show here. The first real use is the capture step of startup-runtime: the package BVH builder throws an HRESULT during the post-confirm load #1758.
  • The HRESULT list is short on purpose; a code outside it prints as HRESULT(0x........) with its facility.
  • Rethrows (null throw info) and 32-bit records (three parameters) are reported as such and not decoded.

AI-assisted; commands listed were executed locally.

R0Y00#1758)

tools/startup/msvc_throw_info.py reads the public x64 throw info (magic, thrown object, _ThrowInfo, _CatchableTypeArray, _CatchableType, type_info name) through a read_mem callback and returns a record with no address and no path: the catchable types (built-in scalars and public library classes by name, any other class as other) and, for a thrown 32-bit scalar such as long, the HRESULT as a public name with its facility. It is not wired into debug_launch.py yet.
@tedin7

tedin7 commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Closing this draft for now to help keep the open PR queue manageable; the branch stays preserved on the fork so it can be reopened once the queue clears.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant