← Back to Pull requests

8396723: Fix JIT compiler crashes caused by AssemblerX86 gtest changing global CPU feature state #34080

Open
unknown opened this pull request with 548 lines diff across 6 files
View on GitHub
unknown unknown commented on Nov 26, 2026 02:21 UTC
Author

This PR fixes the JIT compiler crashes reported due to the mutation of the global CPU feature state by the AssemblerX86 gtest.

Background

AssemblerX86.validate checks HotSpot's x86 instruction encodings byte for byte against GNU as (asmtest.out.h, generated by x86-asmtest.py). This covers encodings, such as AVX-512 and APX, that normal testing cannot run on most hosts.

Problem

To encode every instruction in asmtest.out.h, AssemblerX86.validate changed global VM state at runtime: it set UseAVX=3 and UseAPX=true and added feature bits to VM_Version. Compiler threads (running in parallel) read the same state while they generated code, so they saw inconsistent values and crashed. In the shared VM (TEST_VM, JDK-8396651) the state also stayed inconsistent after the test, because the feature bits were never restored. Running the test in a separate VM (TEST_OTHER_VM, JDK-8396723) did not help, because C1 threads in the child VM could still see the state change.

Fix

Each x86 Assembler now gets its CPU features from an assembler features object instead of from globals:

  • AbstractAssemblerFeatures is a small interface: use_avx(), use_apx(), cpu_supports_evex() and the supports_() queries the assembler uses.

  • HotSpotAssemblerFeatures is the production implementation. It is stateless and forwards each query to the existing flags and VM_Version. It is the default for all existing Assembler and MacroAssembler constructors, so production call sites and generated code are unchanged.

  • Encoding checks in assembler_x86.cpp that affect encoding now go through the assembler's features. This covers UseAVX, UseAPX and VM_Version::supports_(), as well as the InstructionAttr legacy-mode and EVEX address-attribute decisions, and the locate_operand sanity asserts.

  • SyntheticAssemblerFeatures exists only in the test. It enables the full feature set, and the test builds its MacroAssembler with it.
  • The test no longer writes any global flag or feature bit. It runs as a normal TEST_VM test, and every other thread always sees the real host configuration. Because the test only compares bytes and never executes the generated code, it runs on any x86_64 host, including hosts without AVX-512 or APX. asmtest.out.h is unchanged.

    Testing

  • Linux x86_64 (GCC), fastdebug and release: GTestWrapper.java passed. All gtests passed, including AssemblerX86.validate_vm.

  • Windows x86_64 (MSVC), fastdebug and release: GTestWrapper.java passed. The full gtest suite also passed with -XX:UseAVX=2 (EVEX disabled in production assemblers), and compiler/vectorization passed with -XX:UseAVX=2.

  • Full corpus: the full instruction set generated by x86-asmtest.py --full (62,802 cases) passed on Linux.
  • ---------

  • I confirm that I make this contribution in accordance with the OpenJDK Interim AI Policy.
  • <!-- Anything below this marker will be automatically updated, please do not edit manually! -->
    ---------

    Progress


  • \[x\] Change must not contain extraneous whitespace

  • \[x\] Commit message must refer to an issue

  • \[ \] Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)
  • Issue


    * JDK-8396723: Fix JIT compiler crashes caused by AssemblerX86 gtest changing global CPU feature state (Bug - P3)

    Reviewing


    <details><summary>Using <code>git</code></summary>

    Checkout this PR locally: \
    $ git fetch https://git.openjdk.org/jdk.git pull/34080/head:pull/34080 \
    $ git checkout pull/34080

    Update a local copy of the PR: \
    $ git checkout pull/34080 \
    $ git pull https://git.openjdk.org/jdk.git pull/34080/head

    </details>
    <details><summary>Using Skara CLI tools</summary>

    Checkout this PR locally: \
    $ git pr checkout 34080

    View PR using the GUI difftool: \
    $ git pr show -t 34080

    </details>
    <details><summary>Using diff file</summary>

    Download this PR as a diff file: \
    <a href="https://git.openjdk.org/jdk/pull/34080.diff">https://git.openjdk.org/jdk/pull/34080.diff</a>

    </details>
    <details><summary>Using Webrev</summary>

    Link to Webrev Comment
    </details>

    Diff: 548 lines (+411 / -137) across 6 files Reviewer: vnkozlov Review duration: 7545m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.48) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 548 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.377
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #34080"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 48.1% (MEDIUM) · Higher = larger blast radius
    48.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.4% · Safe to merge
    27.4%
    Repository