startup: decode the MSVC C++ exception record into a sanitized summary #1932
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1939"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T21:56:47Z.
Part of #1758 (and #870)
What this unblocks: the startup debugger can report which HRESULT a C++ exception carried when a run ends on
0xE06D7363, as a short public summary with no address, path or name from the title.This is the decoder only: it is not wired into
tools/startup/debug_launch.py(untouched, so it does not collide with the other open PRs that edit that file). The follow-up that calls it at the first-chance stop is a separate change.Source: the MSVC runtime header
ehdata.h(shipped with the Visual Studio C runtime sources) for the0xE06D7363parameters and the_ThrowInfo/_CatchableTypeArray/_CatchableTypelayout; Raymond Chen, The Old New Thing (Microsoft Dev Blogs), "Decoding the parameters of a thrown C++ exception (0xE06D7363)"; Microsoft Learn, "EXCEPTION_RECORD structure (winnt.h)"; Microsoft Learn, "DXGI_ERROR" and "Direct3D 12 return codes", andwinerror.h(Windows SDK) for the HRESULT names and values.Verification (head
49ca19e34, origin/main9b45cbb44merged in with a merge commit):x2w_pipe.py win2025 1939 --host proxmox --regex '^startup_msvc_throw_info$':ctest --preset dev -R '^startup_msvc_throw_info$' --no-tests=error --output-on-failure: 1/1 passed (startup_msvc_throw_info)./O2:ctest --preset release -R '^startup_msvc_throw_info$' --no-tests=error --output-on-failure: 1/1 passed (startup_msvc_throw_info).python3 -B tests/startup_msvc_throw_info_check.pyPASS;tests/docs_links_check.py,tests/bidi_controls_check.py,tests/startup_tools_lint_check.pypass;git diff --check origin/main...HEADclean.What it does
tools/startup/msvc_throw_info.pyturns a0xE06D7363exception record into a sanitized summary. #1758 needs the thrown HRESULT of the BVH builder, whose throw info says the catchable type is the built-inlong(.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 oftype_info, whose decorated name is at offset 16.read_mem(address, size) -> bytes | Noneis the only access to memory, so the core has no Win32 dependency: indebug_launch.pyit would be the existingread.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 isother, 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_*, commonHRESULT_FROM_WIN32(...)), orunrecognized_failurefor a high-bit value outside the list (no bits, code or facility), with the facility category of a listed one (win32,dxgi,d3d12,other). A positive number above 65535 is not reported.describe(record)gives a one-line form made of those fields only.Test
tests/startup_msvc_throw_info_check.pybuilds synthetic exception records in a fake address space (no title data) and checks 89 cases: ten HRESULTs through.J(E_INVALIDARG,E_OUTOFMEMORY,DXGI_ERROR_DEVICE_REMOVED, a generic one, ...),.Hand.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, alongof 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.txtafterstartup_triage_runand in the Python check list of.github/workflows/windows.ymlnext tostartup_triage_run_check.py.Results (Linux, local; mutation and merge-tree runs at the earlier head
9a3c446bb)python3 -B tests/startup_msvc_throw_info_check.py: 89 ok, PASS (head49ca19e34).msvc_throw_info.py, each restored withgit checkout --; all nine fail the test: magic not checked, facility0x87Achanged to0x87B, cap>=instead of>, other classes reported by name, negative count accepted, type name read at +8, scalar size not checked, two DXGI names swapped, a raising callback not caught.tests/docs_links_check.pyandtests/bidi_controls_check.pypass;git diff --check origin/main...HEADis clean.git merge-treeof this branch against the head of every open PR (109, including #1408, #1787, #1788, #1789): no conflict thatorigin/maindoes not already have.Not run, not established
unrecognized_failure.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T21:56:58Z.
Codex Review Summary: ❌ Failed
This comment shows the latest Codex review activity on this pull request.
We couldn’t complete this review. Comment
@codex reviewto try again.49ca19eℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T22:18:58Z.
Review: CHANGES_REQUESTED
Please tighten the public summary allowlist.
_describe_valuetreats every 32-bit scalar with bit 31 set as an HRESULT, then emits its raw hex in both the record and the one-line description. A thrown integer with that bit set can be private application data. Keep named, recognized HRESULTs such as E_INVALIDARG, and classify an unrecognized high-bit value without printing its bits in the shareable output. Add a synthetic scalar sentinel and check both the returned record anddescribe(). The core can still run independently of the startup debugger.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:49:02Z.
Addressed in
9a3c446b._describe_valuenow names only recognized public HRESULTs (E_INVALIDARG and the other table entries keep their name, facility and code).unrecognized_failure(value and category): no code, no bits, no facility, in both the record anddescribe().0xDEADBEEF,0x80041234,0x887A9999,0xCAFE0001) are checked in the returned record and in thedescribe()line, in hex, unsigned and signed decimal. It fails on the previous head (mismatch) and passes now.Verification:
python3 -I tests/startup_msvc_throw_info_check.py: PASS locally (Linux).python3 /root/.local/state/xbox2windows/pipeline/x2w_pipe.py win2025 1939 --regex startup_msvc_throw_info: Win2025 (Build 26100, MSVC 14.44, WARP), Debug and Releasectest -R startup_msvc_throw_info1/1 passed each, at9a3c446b.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:50:39Z.
Closing this PR for now to keep the Windows test queue short. Nothing is wrong with it and the branch stays as it is.
We will reopen it once the queue is clear, re-run the Win2025 WARP checks at its head, and post the result here.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T10:44:13Z.
Reopened and brought up to date: origin/main (
9b45cbb44) merged into the branch with a merge commit (no force push). One conflict inCMakeLists.txt: main addedruntime_startup_triage_run_cli_checkat the same place asstartup_msvc_throw_info; both tests are kept.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
49ca19e344de2afe87ecafbb4f0241bf0e081891:--preset dev):cmake --build --preset dev -- -j 2): 6.76 s (configure 2.52 s)ctest --preset dev -R '^startup_msvc_throw_info$' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (startup_msvc_throw_info0.11 s)/O2(--preset release):cmake --build --preset release -- -j 2): 242.37 s (configure 2.26 s)ctest --preset release -R '^startup_msvc_throw_info$' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (startup_msvc_throw_info0.10 s)Linux at the same head:
python3 -B tests/startup_msvc_throw_info_check.pyPASS (89 checks, including the unrecognized high-bit sentinels from the review: neither the record nordescribe()prints their bits);tests/docs_links_check.py,tests/bidi_controls_check.py,tests/startup_tools_lint_check.pypass;git diff --check origin/main...HEADclean.The description now starts with the
Part of,What this unblocks,Source:andVerification:lines. Still Draft until an independent second check passes.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T11:08:42Z.
@MasterDomino Ready for review: head
49ca19e344de2afe87ecafbb4f0241bf0e081891(decoder only; it is not wired intodebug_launch.py).Independent Stage-2 check on this exact head, Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP), Proxmox slots, dev and release
/O2:Review result: records of a thrown
long(named HRESULTs such asE_INVALIDARGandDXGI_ERROR_DEVICE_REMOVED),int,std::runtime_errorand a class of the title decode as the public layout says; a failure code that is not a public HRESULT is classified without its bits; a class that is not a public library type is reported asotherand never named. Wrong magic, missing image base, shifted throw info, a foreign image base, unreadable memory, a throwing read callback and an over-long name are all refused with a status and no exception; 4000 randomly mutated real records raised nothing and no address, path or title name appeared in any output.Non-blocking: a thrown number up to 65535 is printed as a number (for example
long=5); a private small error code would be visible there. The body already states this limit.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T11:08:53Z.
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T22:04:25Z.
Review: APPROVED
Independently reviewed
49ca19e3integrated overmainae078247(tree826dcb80). The merge is clean (CMakeLists.txtand.github/workflows/windows.ymlauto-merged) andgit diff --cached --check origin/mainis clean.Earlier finding (R0Y00, changes requested on
205803c2): addressed. In_describe_value, a 32-bit value with bit 31 set that is not inHRESULT_NAMESnow returns onlyc_type,hresult=unrecognized_failureandcategory=unrecognized_failure. It has no code, no facility and no bits.describe()builds its line from those fields only. Named HRESULTs keep their name, facility category and code. The sentinels0xDEADBEEF,0x80041234,0x887A9999and0xCAFE0001are checked in both the returned record and thedescribe()line. Restoring the old branch (hresult_name(bits)pluscode) fails them atunrecognized 0xdeadbeef is classified without its bits: MISMATCH.What I traced. I checked the offsets against the public
ehdata.hx64 layout:_ThrowInfo: 16 bytes, with the_CatchableTypeArrayRVA at +12._CatchableType: 28 bytes, with thetype_infoRVA at +4 and the size at +20.TypeDescriptor: the decorated name at +16.I checked the HRESULT table values against
winerror.hand the DXGI/D3D12 return-code lists. Every refusal goes through_refused()with a status only. A class name not on the allowlist is reported asother.What I ran.
devand inrelease. No skips.ok, thenPASS.mainae078247,startup_msvc_throw_infois not registered.Mutants (each applied alone to
tools/startup/msvc_throw_info.py, check rerun, file restored from its raw bytes,git diff --quietclean afterwards). Every one fails the check; the first mismatch is shown:HRESULT(0x…)withcode(the pre-fix form)unrecognized 0xdeadbeef is classified without its bitsdescribe()also printscodeunrecognized 0xdeadbeef: describe line0x7FFFFFFFa large positive number is not reporteda class of the title is 'other'a long of the wrong size has no valuewrong magictype_infoname read at +8long 0x80070057 is E_INVALIDARG>=instead of>16 catchable types is the capNon-blocking notes.
9a3c446b. Under "What it does" and "Not run, not established" it still says an unlisted code prints asHRESULT(0x........)with its facility. The code no longer does that, so the body should sayunrecognized_failure.hresult_name()still returnsHRESULT(0x%08X)for an unlisted value. Nothing in the decoder calls it, but the follow-up that wires this intodebug_launch.pycould reach for it and bring the bits back. Dropping it, or giving it the sameunrecognized_failureanswer, would close that.tests/cmake/<family>.cmakefragment and atests/checks/python-linux/<topic>.txtfile. That keeps them off the shared lines ofCMakeLists.txtand the workflow. Those files are optional, and this merge is clean as it is.Verdict: approve on
49ca19e3.Environment: Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10. No GPU is involved.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass on49ca19e3.This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-28T08:18:25Z.
I reviewed
49ca19e3(no MSVC build). Nothing here looks blocking to me. The code addresses R0Y00's requested change, so I think the PR only needs their re-review. Two small follow-ups are below; pigalot mentioned both as non-blocking.What I checked
main(1f07b2c1) is clean:git merge-tree --write-tree 1f07b2c1 49ca19e3→ rc=0. On that tree,python3 -B tests/startup_msvc_throw_info_check.py→ 89ok,PASS. The Linux CI job ran it too (tests/startup_msvc_throw_info_check.py (ok, 0.1s)).9a3c446b, an unlisted bit-31 value returns onlyunrecognized_failure, and the sentinels are checked in both the record anddescribe().git diff 9a3c446b 49ca19e3 -- tools/startup/msvc_throw_info.py tests/startup_msvc_throw_info_check.pyis empty.ehdata_forceinclude.h, x64_EH_RELATIVE_TYPEINFO 1): the ThrowInfo array RVA is at +12. CatchableType haspTypeat +4 and the size at +20 (28 bytes). The TypeDescriptor name is at +16, the magic is0x19930520, andEH_EXCEPTION_PARAMETERSis 4. All 33HRESULT_NAMESentries match the SDK'swinerror.h./MDprobe under Wine threw 11 objects, and a vectored handler dumped each 0xE06D7363 record (12 with the rethrow). The decoder gave the expected line for all of them, with no address or class name in any output. Examples:long=E_INVALIDARG category=win32,unsigned_int=unrecognized_failure,types=other,other count=2for a private class,no_throw_infofor the rethrow. That is clang-cl with Wine's vcruntime, not MSVC on Windows, but it covers some of the "no real exception record" gap the body lists.Suggestions
grep -c 'HRESULT(0x'on the body → 2). Under "What it does": "orHRESULT(0x........), with its facility category". Under "Not run": "a code outside it prints asHRESULT(0x........)with its facility". Both could now sayunrecognized_failure.hresult_name()still returnsHRESULT(0x%08X)for an unlisted code. Nothing calls it yet, but thedebug_launch.pyfollow-up might, and that would bring the bits back. The test checks it only with a listed value, so a mutant that returnsunrecognized_failurethere still passes. ReturningUNRECOGNIZED_HRESULT(or dropping the helper) plus one unlisted-sentinel check would pin it.SMALL_VALUE_LIMITto0xFFFFFF, or<=→<..K: removing it fromSCALARS_32.S_FALSE: a thrownint1 is reported asS_FALSE category=success, because the table lookup runs before the small-number branch.Cases for 65535 and 65536, one
.Kand oneint1 would cover them.This comment was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-28T21:58:13Z.
Thanks @JohnConnorNPC. Pushed
b055cab96(origin/main merged with a merge commit, no force push).What changed:
HRESULT(0x........); it saysunrecognized_failure.hresult_name()now returnsunrecognized_failurefor an unlisted value, so no caller can bring the bits back..K) scalar, a thrown int 1 (the listedS_FALSE), and an unlisted value throughhresult_name.SMALL_VALUE_LIMITraised,<=changed to<,.Kremoved fromSCALARS_32,hresult_nameprinting bits again.Verification:
python3 -B tests/startup_msvc_throw_info_check.py-> PASS.b055cab96:x2w_pipe.py win2025 1939 --regex '^startup_msvc_throw_info$'-> 1/1 passed in both legs.@MasterDomino ready for review and merge when you have time. The earlier changes-requested review by @R0Y00 (unrecognized high-bit values) is fixed on this head and approved by pigalot.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-29T05:35:48Z.
Review: APPROVED
Retested
b055cab9integrated overmain212d4b5f(tree29bf8761). The merge is clean andgit diff --cached --check origin/mainis clean. This follows my approval on49ca19e3.What changed since
49ca19e3.git diff 49ca19e3 b055cab9on the PR's two files is 3 lines of code and 11 lines of test:hresult_name()returnsunrecognized_failurefor an unlisted value. It no longer formats the bits..Kscalar, a thrownint1 as the listedS_FALSE, andhresult_nameof an unlisted value (unsigned and signed).The merge of
main(d45d241a) has an emptygit show --remerge-diff, so it resolved nothing by hand.Earlier findings.
205803c2(an unrecognized high-bit value printed its bits): still addressed._describe_valueis unchanged since9a3c446b, and the four sentinel checks on the record and ondescribe()still pass.hresult_name(): addressed.grepforHRESULT(0xin the tree finds nothing now.HRESULT(0x........). Two smaller leftovers are under "Non-blocking" below.What I ran.
devand inrelease. No skips.ok, thenPASS.tests/docs_links_check.py,tests/bidi_controls_check.py,tests/startup_tools_lint_check.py.49ca19e3fails with one line,hresult_name of an unlisted value prints no bits: MISMATCH. The other four new checks pass there, as expected: they pin behaviour that was already right.Mutants (each applied alone to
tools/startup/msvc_throw_info.py, check rerun, file restored from its raw bytes,git diff --quietclean afterwards).Killed (11), with the first failing check:
hresult_nameprintsHRESULT(0x…)againhresult_name of an unlisted value prints no bitshresult_namewithout the 32-bit maskhresult_name wraps to 32 bitsSMALL_VALUE_LIMITraised to0xFFFFFFa thrown long 65536 is not reportedSMALL_VALUE_LIMITraised to0x10000SMALL_VALUE_LIMITlowered to0xFFFEa thrown long 65535 is reported<=changed to<.Kremoved fromSCALARS_32KeyError: 'value'in the.Kcheck.Knamedunsigned intan unsigned long is a scalarS_FALSEremoved from the tableKeyError: 'hresult'in theint1 checksuccessa small number is reported as a numberSurviving: none.
Equivalent (1):
.Kmarked signed. The value is masked with0xFFFFFFFFstraight afterstruct.unpack, so the signed flag cannot change any output.Non-blocking.
49ca19e34, and "Test" still says 89 cases. It is 94 at this head.int1 is reported asS_FALSE category=success. The new check pins that on purpose. A thrown 1 that is a plain number reads as an HRESULT there, which is harmless for the summary but worth knowing when reading one.No title run: this PR adds a standalone Python decoder and its check, and nothing in the runtime or the launcher calls it.
Verdict: approve on
b055cab9. I am not merging it in this pass. R0Y00's changes request from205803c2is still formally open on the PR; the code has met it since9a3c446b.Environment: Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10. No GPU is involved.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass onb055cab9.This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-29T13:11:07Z.
Thanks for
b055cab9. I re-checked it against currentmain(c04e0dd6). All three suggestions from my 11-28 comment are answered:python3 -B tests/startup_msvc_throw_info_check.pyon the head givesPASS(rc=0, 94oklines).SMALL_VALUE_LIMITto0xFFFFFFfailsa thrown long 65536 is not reported: MISMATCH. Changingbits <= SMALL_VALUE_LIMITto<failsa thrown long 65535 is reported: MISMATCH. Removing.KfromSCALARS_32makes the check raise. Makinghresult_name()printHRESULT(0x%08X)again failshresult_name of an unlisted value prints no bits: MISMATCH.The branch conflicts with
mainagain, inCMakeLists.txtonly:git merge-tree --write-tree c04e0dd6 b055cab9exits 1. #3198 addedstartup_refusal_censusat the same spot where this PR addsstartup_msvc_throw_info, and keeping bothadd_testblocks resolves it. Could you mergemain(or rebase)? After that, R0Y00's changes request on205803c2still needs their re-review, since the code meets it.Environment: Linux only: git objects,
git merge-tree, and the Python check with four mutants on scratch copies.This comment was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-30T13:57:22Z.
Merged current
main(077bff3ac) to resolve conflicts; sanitized exception decoder and triage checks pass locally. Ready for re-review.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T03:32:59Z.
Review: APPROVED
Re-reviewed
20910f46in a clean trial merge ontoaa70e516. This addresses my earlier request:_describe_value()emits the code only for names inHRESULT_NAMES, and both the record and its shareable line classify an unrecognized high-bit scalar without exposing the bits. The synthetic suite passed all 94 checks (python -B tests/startup_msvc_throw_info_check.py); the adjacentstartup_triage_run_check.pyandstartup_tools_lint_check.pyalso passed. In the trial tree, adding the rawcodeback only in the unrecognized-failure record failed all four synthetic sentinel cases. The fixture remains registered in CTest and Linux CI.