JDK-8318183 : C2: VM may crash after hitting node limit
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 17,21,22
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-10-16
  • Updated: 2024-02-20
  • Resolved: 2023-10-18
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 21 JDK 22
17.0.11Fixed 21.0.2Fixed 22 b20Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
When processing the node limit, as well as when bailing out of compilation for other reasons, we run `Compiler::record_failure()` which sets the root node of Compile to null.

We then should stop any further work that may use Compile::_root. That does not always happen. The results are crashes or asserts when the node limit check hit right at the wrong spot. One example for a follow-up assertion after the node limit hit:

```
#  Internal Error (/shared/projects/openjdk/jdk-jdk/source/src/hotspot/share/opto/loopnode.hpp:623), pid=761308, tid=761322
#  assert(_head != nullptr) failed: precond
```
at
```
Stack: [0x00007fa068281000,0x00007fa068382000],  sp=0x00007fa06837cd40,  free space=1007k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x114ad1c]  IdealLoopTree::IdealLoopTree(PhaseIdealLoop*, Node*, Node*)+0x14c  (loopnode.hpp:623)
V  [libjvm.so+0x11412bf]  PhaseIdealLoop::build_and_optimize()+0x237  (loopnode.cpp:4325)
V  [libjvm.so+0x96e7ac]  PhaseIdealLoop::PhaseIdealLoop(PhaseIterGVN&, LoopOptsMode)+0x144  (loopnode.hpp:1112)
V  [libjvm.so+0x96e9fa]  PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x4a  (loopnode.hpp:1191)
V  [libjvm.so+0x960394]  Compile::Optimize()+0x98c  (compile.cpp:2357)
```

I saw this during the development of JDK-8318016, which re-uses the node limit check for memory limit checks, so those code paths are executed more often.


Comments
[jdk17u-fix-request] Approval Request from Aleksey Shipilëv Semi-clean backport to solve a potential VM crash due to C2 failing. Applies with minor conflicts. 17u PR acked by Paul Hohensee. Testing passes.
19-12-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u-dev/pull/2044 Date: 2023-12-11 20:03:43 +0000
12-12-2023

[jdk21u-fix-request] Approval Request from Aleksey Shipilëv Clean backport to improve C2 reliability. Applies cleanly. Testing passes.
03-11-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk21u/pull/314 Date: 2023-11-01 16:45:22 +0000
01-11-2023

Changeset: 31ef400f Author: Thomas Stuefe <stuefe@openjdk.org> Date: 2023-10-18 08:39:00 +0000 URL: https://git.openjdk.org/jdk/commit/31ef400f31b1fd9a861870cce69f6d3eec72aa46
18-10-2023

ILW = Asserts / crashes in C2 due to hitting node limit, never observed with current code, no workaround but increase node limit = HLM = P3
17-10-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/16205 Date: 2023-10-16 16:57:03 +0000
17-10-2023