JDK-8366138 : Parse::jump_switch_ranges() could cause stack overflow when compiling huge switch statement
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 17
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2025-08-26
  • Updated: 2025-08-29
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 26
26Unresolved
Related Reports
Relates :  
Description
This is another problem exposed by JDK-8366118. When C2 tries to compile a huge switch statement, `Parse::jump_switch_ranges()` could recursively call itself for >1000 times, causing stack overflow and crash the JVM. These crashes are extremely hard to debug without a feature like JDK-8364654, because such stack overflow crashes do not have stack trace, hs-err log or core dump.

After JDK-8366118 is fixed, this type of crash should not normally occur since `-XX:+DontCompileHugeMethods` is the default. But adventurously users could set `-XX:-DontCompileHugeMethods` and run into such crashes.

(Currently we have not found a local repro, but we will keep experimenting and try providing a repro soon.)
Comments
Assuming default value of DontCompileHugeMethods works as expected (see JDK-8366118): ILW = Crash due to stack overflow in C2 compiler, edge case with non-default -XX:DontCompileHugeMethods, exclude method from compilation = HLM = P3
29-08-2025