Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid stack map frames found for MethodAccess subclasses #61

Open
idelvall opened this issue May 25, 2018 · 1 comment
Open

Invalid stack map frames found for MethodAccess subclasses #61

idelvall opened this issue May 25, 2018 · 1 comment

Comments

@idelvall
Copy link

idelvall commented May 25, 2018

When instrumenting this example with our agent:

package main;

import com.esotericsoftware.reflectasm.MethodAccess;

public class Main {

  public static void main(String[] args) {
    StringBuilder obj = new StringBuilder("ff");
    MethodAccess access = MethodAccess.get(obj.getClass());
    System.out.println(access.invoke(obj, "toString"));
  }
}

I am getting this error when our ASM dependency (6.1.1) tries to parse the generated subclass bytecode reflectasm/java/lang/StringBuilderMethodAccess:

<< 2018-05-25 10:45:06.643 ERROR 1 Error found instrumenting class reflectasm/java/lang/StringBuilderMethodAccess
<< java.lang.IllegalArgumentException
<< 	at org.objectweb.asm.ClassReader.readVerificationTypeInfo(ClassReader.java:3138)
<< 	at org.objectweb.asm.ClassReader.readStackMapFrame(ClassReader.java:3065)
<< 	at org.objectweb.asm.ClassReader.readCode(ClassReader.java:1812)
<< 	at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1238)
<< 	at org.objectweb.asm.ClassReader.accept(ClassReader.java:631)
<< 	at org.objectweb.asm.ClassReader.accept(ClassReader.java:355)
<< 	at io.shiftleft.bctrace.asm.Transformer.transform(Transformer.java:128)
<< 	at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
<< 	at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)
<< 	at java.lang.ClassLoader.defineClass1(Native Method)
<< 	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
<< 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
<< 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
<< 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
<< 	at java.lang.reflect.Method.invoke(Method.java:498)
<< 	at com.esotericsoftware.reflectasm.AccessClassLoader.defineClass(AccessClassLoader.java:85)
<< 	at com.esotericsoftware.reflectasm.MethodAccess.get(MethodAccess.java:254)
<< 	at main.Main.main(Main.java:9)

After debugging this I see the reason is an invalid value of 12 (ITEM_ASM_SHORT) for a verification_type_info of a stack map frame.

I am not sure yet if this is caused by your implementation, or by the ASM dependency your are using, but this bytecode is not valid, and we are suspecting it's one of the reasons for SIGSEGV JVM crashes we are experiencing in some environments.

@NathanSweet
Copy link
Member

NathanSweet commented Jun 11, 2018

Maybe this is fixed in ASM 6.2?

Note the given example code is working with ASM 5.1. It might be worth bringing up with the ASM guys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants