-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
6
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.6.0_05"
Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
The verfier in the latest 1.6.0 releases seem to behave different for this class file. The input class (and the source it was created from) is a bit silly, but I ran across this in the real world
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run this program with 1.6.0_04 (or 05) and you should get a VerifyError
Running the same program with 1.6.0_03 (or 02) and no such error is thrown
The setting of maxStack to zero is a reasonable outcome of class transformer that is recalculating max stack. The instructions from offset 3 to 5 are unreachable (see javap output below)
public static void main(java.lang.String[]) throws java.sql.SQLException;
Code:
Stack=0, Locals=2, Args_size=1
0: goto 6
3: astore_1
4: aload_1
5: athrow
6: return
Exception table:
from to target type
3 4 3 any
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Not actually sure who is wrong in this equation. The verifier behavior difference is a little confusing, and it seems that it shouldn't bother with dead code paths with regards to maxStack.
javac also seems to be producing a strange class to begin with, so maybe that is another issue.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.VerifyError: (class: Foo, method: main signature: ([Ljava/lang/String;)V) Stack size too large
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2395)
at java.lang.Class.getMethod0(Class.java:2642)
at java.lang.Class.getMethod(Class.java:1579)
at Test.defineAndInvokeMain(Test.java:15)
at Test.main(Test.java:11)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Test {
public static void main(String[] args) throws Exception {
defineAndInvokeMain(clazz);
// change maxStack to zero for main([Ljava/lang/String;)V
clazz[257] = 0;
// Throws VerifyError with 1.6.0_04, 1.6.0_05, 1.5.0_14 and 1.5.0_15
// No error on 1.6.0_02, 1.6.0_03, 1.5.0_13 (and probably others)
defineAndInvokeMain(clazz);
}
static void defineAndInvokeMain(byte[] classBytes) throws Exception {
new Loader().define("Foo", classBytes).getMethod("main",
new Class[]{String[].class}).invoke(null,
new Object[]{new String[]{}});
System.err.println("class defined okay");
}
static class Loader extends ClassLoader {
Class<?> define(String name, byte[] b) {
return defineClass(name, b, 0, b.length);
}
}
/**
* This source code produced the class below using javac from sun 1.5.0_15
* on winXP.
*
* <pre>
* import java.sql.*;
*
* public class Foo {
* public static void main(String[] args) throws SQLException {
* try {
* //
* } catch (Exception e) {
* System.out.println(e);
* } finally {
* //
* }
* }
* }
* </pre>
*/
private static final byte[] clazz = new byte[]{(byte) 202, (byte) 254,
(byte) 186, (byte) 190, (byte) 0, (byte) 0, (byte) 0, (byte) 49,
(byte) 0, (byte) 18, (byte) 10, (byte) 0, (byte) 3, (byte) 0,
(byte) 14, (byte) 7, (byte) 0, (byte) 15, (byte) 7, (byte) 0,
(byte) 16, (byte) 1, (byte) 0, (byte) 6, (byte) 60, (byte) 105,
(byte) 110, (byte) 105, (byte) 116, (byte) 62, (byte) 1, (byte) 0,
(byte) 3, (byte) 40, (byte) 41, (byte) 86, (byte) 1, (byte) 0,
(byte) 4, (byte) 67, (byte) 111, (byte) 100, (byte) 101, (byte) 1,
(byte) 0, (byte) 15, (byte) 76, (byte) 105, (byte) 110, (byte) 101,
(byte) 78, (byte) 117, (byte) 109, (byte) 98, (byte) 101,
(byte) 114, (byte) 84, (byte) 97, (byte) 98, (byte) 108,
(byte) 101, (byte) 1, (byte) 0, (byte) 4, (byte) 109, (byte) 97,
(byte) 105, (byte) 110, (byte) 1, (byte) 0, (byte) 22, (byte) 40,
(byte) 91, (byte) 76, (byte) 106, (byte) 97, (byte) 118, (byte) 97,
(byte) 47, (byte) 108, (byte) 97, (byte) 110, (byte) 103,
(byte) 47, (byte) 83, (byte) 116, (byte) 114, (byte) 105,
(byte) 110, (byte) 103, (byte) 59, (byte) 41, (byte) 86, (byte) 1,
(byte) 0, (byte) 10, (byte) 69, (byte) 120, (byte) 99, (byte) 101,
(byte) 112, (byte) 116, (byte) 105, (byte) 111, (byte) 110,
(byte) 115, (byte) 7, (byte) 0, (byte) 17, (byte) 1, (byte) 0,
(byte) 10, (byte) 83, (byte) 111, (byte) 117, (byte) 114,
(byte) 99, (byte) 101, (byte) 70, (byte) 105, (byte) 108,
(byte) 101, (byte) 1, (byte) 0, (byte) 8, (byte) 70, (byte) 111,
(byte) 111, (byte) 46, (byte) 106, (byte) 97, (byte) 118,
(byte) 97, (byte) 12, (byte) 0, (byte) 4, (byte) 0, (byte) 5,
(byte) 1, (byte) 0, (byte) 3, (byte) 70, (byte) 111, (byte) 111,
(byte) 1, (byte) 0, (byte) 16, (byte) 106, (byte) 97, (byte) 118,
(byte) 97, (byte) 47, (byte) 108, (byte) 97, (byte) 110,
(byte) 103, (byte) 47, (byte) 79, (byte) 98, (byte) 106,
(byte) 101, (byte) 99, (byte) 116, (byte) 1, (byte) 0, (byte) 21,
(byte) 106, (byte) 97, (byte) 118, (byte) 97, (byte) 47,
(byte) 115, (byte) 113, (byte) 108, (byte) 47, (byte) 83,
(byte) 81, (byte) 76, (byte) 69, (byte) 120, (byte) 99, (byte) 101,
(byte) 112, (byte) 116, (byte) 105, (byte) 111, (byte) 110,
(byte) 0, (byte) 33, (byte) 0, (byte) 2, (byte) 0, (byte) 3,
(byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 2,
(byte) 0, (byte) 1, (byte) 0, (byte) 4, (byte) 0, (byte) 5,
(byte) 0, (byte) 1, (byte) 0, (byte) 6, (byte) 0, (byte) 0,
(byte) 0, (byte) 29, (byte) 0, (byte) 1, (byte) 0, (byte) 1,
(byte) 0, (byte) 0, (byte) 0, (byte) 5, (byte) 42, (byte) 183,
(byte) 0, (byte) 1, (byte) 177, (byte) 0, (byte) 0, (byte) 0,
(byte) 1, (byte) 0, (byte) 7, (byte) 0, (byte) 0, (byte) 0,
(byte) 6, (byte) 0, (byte) 1, (byte) 0, (byte) 0, (byte) 0,
(byte) 3, (byte) 0, (byte) 9, (byte) 0, (byte) 8, (byte) 0,
(byte) 9, (byte) 0, (byte) 2, (byte) 0, (byte) 6, (byte) 0,
(byte) 0, (byte) 0, (byte) 47, (byte) 0, (byte) 1, (byte) 0,
(byte) 2, (byte) 0, (byte) 0, (byte) 0, (byte) 7, (byte) 167,
(byte) 0, (byte) 6, (byte) 76, (byte) 43, (byte) 191, (byte) 177,
(byte) 0, (byte) 1, (byte) 0, (byte) 3, (byte) 0, (byte) 4,
(byte) 0, (byte) 3, (byte) 0, (byte) 0, (byte) 0, (byte) 1,
(byte) 0, (byte) 7, (byte) 0, (byte) 0, (byte) 0, (byte) 14,
(byte) 0, (byte) 3, (byte) 0, (byte) 0, (byte) 0, (byte) 11,
(byte) 0, (byte) 3, (byte) 0, (byte) 9, (byte) 0, (byte) 6,
(byte) 0, (byte) 12, (byte) 0, (byte) 10, (byte) 0, (byte) 0,
(byte) 0, (byte) 4, (byte) 0, (byte) 1, (byte) 0, (byte) 11,
(byte) 0, (byte) 1, (byte) 0, (byte) 12, (byte) 0, (byte) 0,
(byte) 0, (byte) 2, (byte) 0, (byte) 13};
}
---------- END SOURCE ----------
Release Regression From : 6u3
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.
java version "1.6.0_05"
Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
The verfier in the latest 1.6.0 releases seem to behave different for this class file. The input class (and the source it was created from) is a bit silly, but I ran across this in the real world
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run this program with 1.6.0_04 (or 05) and you should get a VerifyError
Running the same program with 1.6.0_03 (or 02) and no such error is thrown
The setting of maxStack to zero is a reasonable outcome of class transformer that is recalculating max stack. The instructions from offset 3 to 5 are unreachable (see javap output below)
public static void main(java.lang.String[]) throws java.sql.SQLException;
Code:
Stack=0, Locals=2, Args_size=1
0: goto 6
3: astore_1
4: aload_1
5: athrow
6: return
Exception table:
from to target type
3 4 3 any
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Not actually sure who is wrong in this equation. The verifier behavior difference is a little confusing, and it seems that it shouldn't bother with dead code paths with regards to maxStack.
javac also seems to be producing a strange class to begin with, so maybe that is another issue.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.VerifyError: (class: Foo, method: main signature: ([Ljava/lang/String;)V) Stack size too large
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2395)
at java.lang.Class.getMethod0(Class.java:2642)
at java.lang.Class.getMethod(Class.java:1579)
at Test.defineAndInvokeMain(Test.java:15)
at Test.main(Test.java:11)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Test {
public static void main(String[] args) throws Exception {
defineAndInvokeMain(clazz);
// change maxStack to zero for main([Ljava/lang/String;)V
clazz[257] = 0;
// Throws VerifyError with 1.6.0_04, 1.6.0_05, 1.5.0_14 and 1.5.0_15
// No error on 1.6.0_02, 1.6.0_03, 1.5.0_13 (and probably others)
defineAndInvokeMain(clazz);
}
static void defineAndInvokeMain(byte[] classBytes) throws Exception {
new Loader().define("Foo", classBytes).getMethod("main",
new Class[]{String[].class}).invoke(null,
new Object[]{new String[]{}});
System.err.println("class defined okay");
}
static class Loader extends ClassLoader {
Class<?> define(String name, byte[] b) {
return defineClass(name, b, 0, b.length);
}
}
/**
* This source code produced the class below using javac from sun 1.5.0_15
* on winXP.
*
* <pre>
* import java.sql.*;
*
* public class Foo {
* public static void main(String[] args) throws SQLException {
* try {
* //
* } catch (Exception e) {
* System.out.println(e);
* } finally {
* //
* }
* }
* }
* </pre>
*/
private static final byte[] clazz = new byte[]{(byte) 202, (byte) 254,
(byte) 186, (byte) 190, (byte) 0, (byte) 0, (byte) 0, (byte) 49,
(byte) 0, (byte) 18, (byte) 10, (byte) 0, (byte) 3, (byte) 0,
(byte) 14, (byte) 7, (byte) 0, (byte) 15, (byte) 7, (byte) 0,
(byte) 16, (byte) 1, (byte) 0, (byte) 6, (byte) 60, (byte) 105,
(byte) 110, (byte) 105, (byte) 116, (byte) 62, (byte) 1, (byte) 0,
(byte) 3, (byte) 40, (byte) 41, (byte) 86, (byte) 1, (byte) 0,
(byte) 4, (byte) 67, (byte) 111, (byte) 100, (byte) 101, (byte) 1,
(byte) 0, (byte) 15, (byte) 76, (byte) 105, (byte) 110, (byte) 101,
(byte) 78, (byte) 117, (byte) 109, (byte) 98, (byte) 101,
(byte) 114, (byte) 84, (byte) 97, (byte) 98, (byte) 108,
(byte) 101, (byte) 1, (byte) 0, (byte) 4, (byte) 109, (byte) 97,
(byte) 105, (byte) 110, (byte) 1, (byte) 0, (byte) 22, (byte) 40,
(byte) 91, (byte) 76, (byte) 106, (byte) 97, (byte) 118, (byte) 97,
(byte) 47, (byte) 108, (byte) 97, (byte) 110, (byte) 103,
(byte) 47, (byte) 83, (byte) 116, (byte) 114, (byte) 105,
(byte) 110, (byte) 103, (byte) 59, (byte) 41, (byte) 86, (byte) 1,
(byte) 0, (byte) 10, (byte) 69, (byte) 120, (byte) 99, (byte) 101,
(byte) 112, (byte) 116, (byte) 105, (byte) 111, (byte) 110,
(byte) 115, (byte) 7, (byte) 0, (byte) 17, (byte) 1, (byte) 0,
(byte) 10, (byte) 83, (byte) 111, (byte) 117, (byte) 114,
(byte) 99, (byte) 101, (byte) 70, (byte) 105, (byte) 108,
(byte) 101, (byte) 1, (byte) 0, (byte) 8, (byte) 70, (byte) 111,
(byte) 111, (byte) 46, (byte) 106, (byte) 97, (byte) 118,
(byte) 97, (byte) 12, (byte) 0, (byte) 4, (byte) 0, (byte) 5,
(byte) 1, (byte) 0, (byte) 3, (byte) 70, (byte) 111, (byte) 111,
(byte) 1, (byte) 0, (byte) 16, (byte) 106, (byte) 97, (byte) 118,
(byte) 97, (byte) 47, (byte) 108, (byte) 97, (byte) 110,
(byte) 103, (byte) 47, (byte) 79, (byte) 98, (byte) 106,
(byte) 101, (byte) 99, (byte) 116, (byte) 1, (byte) 0, (byte) 21,
(byte) 106, (byte) 97, (byte) 118, (byte) 97, (byte) 47,
(byte) 115, (byte) 113, (byte) 108, (byte) 47, (byte) 83,
(byte) 81, (byte) 76, (byte) 69, (byte) 120, (byte) 99, (byte) 101,
(byte) 112, (byte) 116, (byte) 105, (byte) 111, (byte) 110,
(byte) 0, (byte) 33, (byte) 0, (byte) 2, (byte) 0, (byte) 3,
(byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 2,
(byte) 0, (byte) 1, (byte) 0, (byte) 4, (byte) 0, (byte) 5,
(byte) 0, (byte) 1, (byte) 0, (byte) 6, (byte) 0, (byte) 0,
(byte) 0, (byte) 29, (byte) 0, (byte) 1, (byte) 0, (byte) 1,
(byte) 0, (byte) 0, (byte) 0, (byte) 5, (byte) 42, (byte) 183,
(byte) 0, (byte) 1, (byte) 177, (byte) 0, (byte) 0, (byte) 0,
(byte) 1, (byte) 0, (byte) 7, (byte) 0, (byte) 0, (byte) 0,
(byte) 6, (byte) 0, (byte) 1, (byte) 0, (byte) 0, (byte) 0,
(byte) 3, (byte) 0, (byte) 9, (byte) 0, (byte) 8, (byte) 0,
(byte) 9, (byte) 0, (byte) 2, (byte) 0, (byte) 6, (byte) 0,
(byte) 0, (byte) 0, (byte) 47, (byte) 0, (byte) 1, (byte) 0,
(byte) 2, (byte) 0, (byte) 0, (byte) 0, (byte) 7, (byte) 167,
(byte) 0, (byte) 6, (byte) 76, (byte) 43, (byte) 191, (byte) 177,
(byte) 0, (byte) 1, (byte) 0, (byte) 3, (byte) 0, (byte) 4,
(byte) 0, (byte) 3, (byte) 0, (byte) 0, (byte) 0, (byte) 1,
(byte) 0, (byte) 7, (byte) 0, (byte) 0, (byte) 0, (byte) 14,
(byte) 0, (byte) 3, (byte) 0, (byte) 0, (byte) 0, (byte) 11,
(byte) 0, (byte) 3, (byte) 0, (byte) 9, (byte) 0, (byte) 6,
(byte) 0, (byte) 12, (byte) 0, (byte) 10, (byte) 0, (byte) 0,
(byte) 0, (byte) 4, (byte) 0, (byte) 1, (byte) 0, (byte) 11,
(byte) 0, (byte) 1, (byte) 0, (byte) 12, (byte) 0, (byte) 0,
(byte) 0, (byte) 2, (byte) 0, (byte) 13};
}
---------- END SOURCE ----------
Release Regression From : 6u3
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.