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

the soot's generated class file can not pass the java verification #1117

Closed
e1iu opened this issue Feb 19, 2019 · 2 comments
Closed

the soot's generated class file can not pass the java verification #1117

e1iu opened this issue Feb 19, 2019 · 2 comments
Labels

Comments

@e1iu
Copy link

e1iu commented Feb 19, 2019

when using soot as an optimizing tool, a generated class file can not run since it refused by java verification.

error message:

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.VerifyError: Bad local variable type
Exception Details:
  Location:
    E1.foo(II)I @13: iload_3
  Reason:
    Type top (current frame, locals[3]) is not assignable to integer
  Current Frame:
    bci: @13
    flags: { }
    locals: { 'java/lang/Exception', integer, integer }
    stack: { }
  Bytecode:
    0x0000000: 1b04 603e bb00 0d59 b700 0ebf 4b1d 0460
    0x0000010: ac
  Exception Handler Table:
    bci [0, 12] => handler: 12
  Stackmap Table:
    same_locals_1_stack_item_frame(@12,Object[#13])

	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
	at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
	at java.lang.Class.getMethod0(Class.java:3018)
	at java.lang.Class.getMethod(Class.java:1784)
	at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
	at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)

I have been already check the java file version and the byte code, but not found any suspicious.

It's a very small class file:

before soot:

int foo(int, int);
   descriptor: (II)I
   flags:
   Code:
     stack=2, locals=4, args_size=3
        0: iload_1
        1: iconst_1
        2: iadd
        3: istore_1
        4: new           #2                  // class java/lang/Exception
        7: dup
        8: invokespecial #3                  // Method java/lang/Exception."<init>":()V
       11: athrow
       12: astore_3
       13: iload_1
       14: iconst_1
       15: iadd
       16: istore_1
       17: iload_1
       18: ireturn
     Exception table:
        from    to  target type
            0    12    12   Class java/lang/Exception

after soot:

int foo(int, int);
    descriptor: (II)I
    flags:
    Code:
      stack=2, locals=4, args_size=3
         0: iload_1
         1: iconst_1
         2: iadd
         3: istore_3
         4: new           #13                 // class java/lang/Exception
         7: dup
         8: invokespecial #14                 // Method java/lang/Exception."<init>":()V
        11: athrow
        12: astore_0
        13: iload_3
        14: iconst_1
        15: iadd
        16: ireturn
      Exception table:
         from    to  target type
             0    12    12   Class java/lang/Exception

test java file:

public class E1 {
  int foo(int a, int b) {
  try{
      a = a + 1;
      throw new Exception();
    }catch (Exception e){
      a = a + 1;
    }

  return a;

  }

  public static void main(String args[]){  
    System.out.println(new E1().foo(1, 2));
  }
}

My java version:

java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)

the problem is that JVM check the class file in each entry separately, in this test case, 12: astore_0 as an entry, but local[3] not initialized.

Maybe it can add a transform to check this situation or fix Jimple in jtp process to solve it.

@e1iu
Copy link
Author

e1iu commented Feb 19, 2019

see #991

@e1iu
Copy link
Author

e1iu commented Feb 26, 2019

disable the jb.ls can solve the problem.

@mbenz89

@mbenz89 mbenz89 added the bug label Feb 26, 2019
@e1iu e1iu closed this as completed Sep 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants