Invalid code generated by C2 compiler in OpenJDK 21

Jaikiran Pai jai.forums2013 at gmail.com
Fri Dec 15 14:28:16 UTC 2023


Hello Antonie,

Just to get the discussion started, what operating system is this 
happening on? Would you be able to provide a stacktrace of this 
exception (you can replace the application specific class/package names 
with some generic values)?

You also note:

 > Issue also happens with fastdebug builds of OpenJDK, without crashing 
due to assertions

In that scenario, what error message (if any) are you seeing?

Finally, at this point, based on the commit you have narrowed this down 
to, this doesn't appear to be a "javac" issue, so compiler-dev mailing 
list wouldn't be appropriate for this discussion. I've now included 
hotspot-runtime-dev mailing list in this discussion (and Bcced 
compiler-dev). You can subscribe here 
https://mail.openjdk.org/mailman/listinfo/hotspot-runtime-dev to receive 
and send replies.

-Jaikiran

On 15/12/23 3:42 pm, Antoine DESSAIGNE wrote:
> Hello everyone,
>
> I've found an issue while migrating to OpenJDK 21. A valued local 
> variable (effectively final) has its value removed and it throws a 
> NullPointerException. Unfortunately, I cannot provide the source code 
> and the data to reproduce the issue, and I couldn't create a smaller 
> code snippet to show the issue. That said, I'll happily show the code 
> and perform many tests during calls.
>
> Here's what I did so far to diagnose the issue.
>
> I bisected the repository to find where the regression comes from. I 
> found this commit 3696711efa5 [1] but it's a merge so I bisected the 
> branch and found 10737e168c9 [2]. Looking at this commit, I have no 
> idea how it could introduce this kind of regression.
>
> Then, thanks to the guidance from Aleksey Shipilëv, I tested many things
> * Issue does *not* happen with the following 
> flags: -Xint, -XX:-TieredCompilation, -XX:TieredStopAtLevel=1, -XX:TieredStopAtLevel=2, -XX:TieredStopAtLevel=3
> * Issue also happens with fastdebug builds of OpenJDK, without 
> crashing due to assertions
> * Issue still happens in the latest version of the code 
> (commit b31454e3623)
> * Issue happens no matter which GC is used, I tried SerialGC, 
> ParallelGC, G1GC, and ShenandoahGC
>
> The tests were performed in Docker containers running on 4 different 
> hosts.
>
> Therefore it looks like C2 is generating an invalid assembly code. 
> Unfortunately, I'm not great with assembly and the generated assembly 
> is quite big (main code is around 20k).
>
> Do you have an idea of why this is happening? Do you know what test I 
> can run? If one of you is available, we can schedule calls for me to 
> show you the code and my tests. Thank you very much for your assistance.
>
> Have a nice day,
>
> Antoine DESSAIGNE
>
> [1] 
> https://github.com/openjdk/jdk/commit/3696711efa566fb776d6923da86e17b0e1e22964
> [2] 
> https://github.com/openjdk/jdk/commit/10737e168c967a08e257927251861bf2c14795ab
>
>


More information about the hotspot-runtime-dev mailing list