Skip to content

fix(libc): report instead of repairing contexts that omit AVX state - #34

Merged
aarvsn merged 1 commit into
aarvsn:mainfrom
xacidr4inx:fix/xstate-report-only
Nov 27, 2026
Merged

aarvsn merged 1 commit into
aarvsn:mainfrom
xacidr4inx:fix/xstate-report-only

Conversation

@xacidr4inx

Copy link
Copy Markdown
Contributor

What

Follow-up to #33. That PR was merged with only its first commit: a vectored-handler repair that writes the omitted AVX state back into an exception context. On an affected kernel this repair can't work, so this PR replaces it.

Background: 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 on the stack (JDK-8365196). The context then omits the AVX state the thread is using.

Why the repair fails: on a player's Windows 11 26200.5761, the upper halves of ymm0-15 were already zero when the vectored handler ran. XINUSE showed AVX not in use, so the handler's XSAVE held only zeros. The true values can't be restored from user mode.

  • The repair is removed: the XSAVE/XRSTOR wrapper, the CPUID 0xD component table, and the context rewrite.
  • The vectored handler is now ReportCrashCheckingXState. When ReportCrash resumes an exception, 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.
  • The TechnicalDebt entry now describes the check.

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 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 full ctest suite was not run (no MSYS2 UCRT64 environment here). No title was run against this branch.

Checklist

🤖 Generated with Claude Code

The repair could not work. On an affected kernel (tested on Windows 11
26200.5761), the AVX state is already lost when a vectored handler runs:
XINUSE shows AVX not in use at the handler, so its XSAVE holds zeros, and
the true upper halves cannot be restored from user mode.

The vectored handler now only recognises a resumed exception whose
compacted XSAVE header omits enabled vector components. It reports the
kernel bug once on stderr, with the fix (the Windows update), and counts
further contexts (first 20, then every 1000th).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aarvsn
aarvsn merged commit c3e193a into aarvsn:main Nov 27, 2026
4 checks passed
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