JDK-8288303 : C1: Miscompilation due to broken Class.getModifiers intrinsic
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 17,18,19
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-06-13
  • Updated: 2022-06-24
  • Resolved: 2022-06-14
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 19 JDK 20
17.0.5-oracleFixed 19 b27Fixed 20Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
Currently, at least one test is timing out:

$ CONF=linux-x86-server-fastdebug make images run-test TEST=jdk/jfr/jvm/TestGetEventWriter.java

It times out only with C1 -Xcomp. It looks as if this loop is reduced to infinite one:

```
package jdk.jfr.internal;

...

public final class Utils {
    ...

    public static void verifyMirror(Class<?> mirror, Class<?> real) {
        Class<?> cMirror = Objects.requireNonNull(mirror);
        Class<?> cReal = Objects.requireNonNull(real);

        Map<String, Field> mirrorFields = new HashMap<>();
        while (cMirror != null) {
            for (Field f : cMirror.getDeclaredFields()) {
                if (isSupportedType(f.getType())) {
                    mirrorFields.put(f.getName(), f);
                }
            }
            cMirror = cMirror.getSuperclass();
        }
        ...
     }
  }
```

Unfortunately, that test is inconvenient to use as the bisection test, because it was only recently added. Luckily, other JFR tests fail as well with the same symptoms:

CONF=linux-x86-server-fastdebug make images run-test TEST=jdk/jfr/api/recording/misc/TestGetStream.java TEST_VM_OPTS="-Xcomp -XX:TieredStopAtLevel=1" JTREG="TIMEOUT_FACTOR=1"

That allows to bisect the hangup to JDK-8265711, which also makes some sense, as the code above calls `isSupportedType` -> `Class.getModifiers`.

While this reliably reproduces on x86_32, I believe the bug is actually generic.
Comments
Fix Request (17u) Fixes the C1 regression, resulting in miscompilation in corner cases. Patch applies cleanly, reproducers now pass, tier1 passes.
22-06-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u-dev/pull/500 Date: 2022-06-22 17:49:02 +0000
22-06-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk18u/pull/166 Date: 2022-06-21 07:56:18 +0000
21-06-2022

Changeset: 8cd87e73 Author: Aleksey Shipilev <shade@openjdk.org> Date: 2022-06-14 14:34:45 +0000 URL: https://git.openjdk.org/jdk19/commit/8cd87e731bcaff2d7838995c68056742d577ad3b
14-06-2022

ILW = infinite loop; JFR test only; disable intrinsic = MMM = P3
13-06-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk19/pull/8 Date: 2022-06-13 13:21:17 +0000
13-06-2022

Good catch, I even mentioned that in the PR: https://github.com/openjdk/jdk/pull/3616#discussion_r621203923
13-06-2022

I actually have a fix. C1 regalloc seems to be confused about branches in that LIR intrinsic code, and going branchless fixes the hang. Testing...
13-06-2022