JDK-8292602 : ZGC: C2 late barrier analysis uses invalid dominator information
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 14,17,20
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-08-18
  • Updated: 2023-01-02
  • Resolved: 2022-09-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17 JDK 20
17.0.7-oracleFixed 20 b17Fixed
Related Reports
Relates :  
Description
Late barrier analysis for ZGC in C2 uses dominator information to elide load barriers. This information is computed at the beginning of the scheduler phase (PhaseCFG::build_dominator_tree()) and is invalidated whenever the block ordering phase (PhaseCFG::fixup_flow()) inserts a new block (PhaseCFG::insert_goto_at()). Invalid dominator information might lead to miscompilation of load barriers, even though no such event has been observed in practice.

The following example illustrates the issue. First, PhaseCFG::build_dominator_tree() computes the dominator tree (immediate dominators and depth) as part of scheduling (after-scheduling.pdf). After register allocation, PhaseCFG::fixup_flow() inserts a "goto" block between B3 and B5 (renamed to B4 and B7 in before-barrier-analysis.pdf). At this point, the dominator information is invalid (B5 lacks an immediate dominator, B7's immediate dominator should be B5, and B7's depth should be 5), and should be repaired or recomputed for a correct late barrier analysis.

Thanks to Nils Eliasson for discovering the issue and providing a tentative solution.
Comments
Fix request [17u] I backport this for parity with 17.0.7-oracle. Typical risk of a C2 change. Has verification code but no test. In 20 for a while now. Clean backport. SAP nightly testing passed.
30-12-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u-dev/pull/997 Date: 2022-12-29 12:20:32 +0000
29-12-2022

Note for backporting: the verification code added by this fix relies on JDK-8292285 and its subsequent fix JDK-8292660.
04-11-2022

Changeset: eec992c6 Author: Roberto CastaƱeda Lozano <rcastanedalo@openjdk.org> Date: 2022-09-23 07:25:07 +0000 URL: https://git.openjdk.org/jdk/commit/eec992c6b0ac77d08478d852a80c9470418d925d
23-09-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/10353 Date: 2022-09-20 07:04:34 +0000
20-09-2022

ILW = Wrong dominator information could lead to miscompilations, with ZGC and not observed in practice yet, use other GC or possibly disable compilation of affected method = HLM = P3
19-08-2022