Crash in valhalla

Remi Forax forax at univ-mlv.fr
Tue Sep 15 21:54:59 UTC 2020


Hi Martijn,
obviously the VM should not crash,
the issue is that an inline class (MyInlineClass) at bytecode level should not have an instance method named <init> but a static method named <init>,
and use defaultvalue + withfield instead of invokespecial <init>() + putfield.

@Tobias, it seems that if an inline class doesn't have a static method <init>, the VM crash.

Using javap, your code is
public value class MyInlineClass {
  private final int i;

  public int i();
    Code:
       0: aload_0
       1: getfield      #13                 // Field i:I
       4: ireturn

  public MyInlineClass(int);     // <---------- WRONG
    Code:
       0: aload_0
       1: iload_1
       2: putfield      #13                 // Field i:I
       5: aload_0
       6: invokespecial #20                 // Method java/lang/Object."<init>":()V
       9: return
}



but it should be
public final value class MyInlineClass {
  private final int i;

  public int i();
    Code:
       0: aload_0
       1: getfield      #3                  // Field i:I
       4: ireturn

  public static MyInlineClass(int);   <---- the method is static here
    Code:
       0: defaultvalue  #1                  // class MyInlineClass
       3: astore_1
       4: iload_0
       5: aload_1
       6: swap
       7: withfield     #3                  // Field i:I
      10: astore_1
      11: aload_1
      12: areturn
}

as a side note, you don't have to generate the instruction swap in the static method <init>, it's an artefact of javac.

regards,
Rémi

----- Mail original -----
> De: "Martijn Hoekstra" <martijnhoekstra at gmail.com>
> À: "Tobias Hartmann" <tobias.hartmann at oracle.com>
> Cc: "valhalla-dev" <valhalla-dev at openjdk.java.net>
> Envoyé: Mardi 15 Septembre 2020 17:59:08
> Objet: Re: Crash in valhalla

>>
>>
>> Hi Martijn,
>>
>> Thanks for trying out Valhalla!
>>
>> On 15.09.20 17:17, Martijn Hoekstra wrote:
>> > Are reports of these kinds of things valuable yet? If so, where/how can I
>> > report it?
>>
>> Yes, such feedback is very much appreciated. Feel free to simply share
>> the details here (maybe upload the hs_err* file and reproducer somewhere
>> and send the link).
>>
>> Thanks,
>> Tobias
>>
> 
> Hi Tobias,
> 
> Thanks for the quick response.
> 
> I have a link with log, dump and class files here:
> https://1drv.ms/u/s!Aukg503a2UkIg9NFE7NcQOFg_oKvOQ?e=NnpPCW


More information about the valhalla-dev mailing list