Skip to content

fix(libc): report Windows kernels that omit AVX state from exception contexts - #33

Merged
aarvsn merged 1 commit into
aarvsn:mainfrom
xacidr4inx:fix/xstate-stale-header
Nov 26, 2026
Merged

aarvsn merged 1 commit into
aarvsn:mainfrom
xacidr4inx:fix/xstate-stale-header

Conversation

@xacidr4inx

@xacidr4inx xacidr4inx commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What

On Windows 11 24H2/25H2 kernels before 26100.7920 (OS build 26100.7922, KB5077241), and on Windows Server 2025, the kernel can build a user-mode exception's context from a stale XSAVE header left on the stack (JDK-8365196, reproducer and kernel survey). The context then omits the AVX state the thread is using. The upper halves of ymm0-15 and the AVX-512 state are already zero when a vectored handler runs, and the resume keeps them zero.

A converted PS4 title (GT7) crashed this way when Ryty resumed a guest write fault: a job object's two 256-bit stores lost their upper 16 bytes. On the player's Windows 11 26200.5761, the resumed contexts had XSTATE_BV 0 and XCOMP_BV 0x8000000000000000, a stale -0.0/INT64_MIN on the stack.

This can't be repaired from user mode. The first version of this PR wrote the components back from an XSAVE taken in the handler. On the affected machine, AVX was already not in use (XINUSE) at that point, so there was nothing to write back. That repair is removed.

What the PR does now:

  • The vectored handler is ReportCrashCheckingXState. When ReportCrash resumes an exception (EXCEPTION_CONTINUE_EXECUTION), it checks whether the context's compacted XSAVE header omits enabled vector components (XCR0 bits 2, 5, 6, 7). It only reads the context.
  • The first such context reports the kernel bug on stderr with the fix (install the latest Windows update). Later ones are counted: the first 20, then every 1000th, with the header and rip.
  • docs/dev/TechnicalDebt.md records the check and when it can go.

Tested

  • MSYS2 UCRT64 GCC 16.2.0 (not the 15.2.0 winlibs build the README names): CrashReport.cpp compiles with -std=c++20 -Wall, no warnings.
  • A harness built with the same compiler uses the new check function verbatim. A write fault on a PAGE_READONLY page with a complete context is not reported. The same fault, with the context's header set to what an affected kernel produces (XSTATE_BV 0, XCOMP_BV 0x8000000000000000), is reported with 0xe4 omitted.
  • Machine: Windows 10 19044, Ryzen 7 7745HX. This kernel is not affected, so the stale header was simulated.
  • The bug itself was observed in a log from a Windows 11 26200.5761 player, using the same check in a downstream renderer.
  • The full ctest suite was not run (no MSYS2 UCRT64 environment here). No title was run against this branch.

Checklist

  • Based on current main
  • One topic
  • No comments in code; the check is listed in TechnicalDebt
  • Depends on: none
  • AI-assisted: yes (Claude Code), reviewed by me

🤖 Generated with Claude Code

…ws 11 kernels

Windows 11 24H2/25H2 kernels before 26100.7920 (and Windows Server 2025)
can build a user-mode exception's context from a stale XSAVE header left
on the stack (JDK-8365196). The context then omits AVX state the thread
uses, and resuming from it zeroes the upper halves of ymm0-15 and the
AVX-512 state. A guest store that faults on a write-watched page and is
resumed by ReportCrash then writes zeros where those halves belong.

The vectored handler now takes an XSAVE of the vector components on
entry, and before an EXCEPTION_CONTINUE_EXECUTION writes the components
in use that the context omits back into its XSAVE area and fixes the
header, so the resume restores them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aarvsn
aarvsn merged commit 98f5076 into aarvsn:main Nov 26, 2026
4 checks passed
@xacidr4inx xacidr4inx changed the title fix(libc): keep AVX state across resumed exceptions on affected Windows 11 kernels fix(libc): report Windows kernels that omit AVX state from exception contexts Nov 26, 2026
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.

2 participants