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

J9 (1.8.0_275) threw an AssertionError; J9 (11.0.9) threw an ArrayIndexOutOfBoundsException; OpenJDK (8u275, 9.0.4, 11.0.9) and J9 (9.0.4) threw an VerifyError; #11685

Closed
fuzzy000 opened this issue Jan 19, 2021 · 4 comments · Fixed by #11753

Comments

@fuzzy000
Copy link

JVM Versions

We used the following versions of J9:

openjdk version "1.8.0_275"
OpenJDK Runtime Environment (build 1.8.0_275-b01)
Eclipse OpenJ9 VM (build openj9-0.23.0, JRE 1.8.0 Linux amd64-64-Bit Compressed References 20201110_845 (JIT enabled, AOT enabled)
OpenJ9   - 0394ef754
OMR      - 582366ae5
JCL      - b52d2ff7ee based on jdk8u275-b01)
openjdk version "9.0.4-adoptopenjdk"
OpenJDK Runtime Environment (build 9.0.4-adoptopenjdk+12)
Eclipse OpenJ9 VM (build openj9-0.9.0, JRE 9 Linux amd64-64-Bit Compressed References 20180814_248 (JIT enabled, AOT enabled)
OpenJ9   - 24e53631
OMR      - fad6bf6e
JCL      - feec4d2ae based on jdk-9.0.4+12)
openjdk version "11.0.9" 2020-10-20
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9+11)
Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.23.0, JRE 11 Linux amd64-64-Bit Compressed References 20201022_810 (JIT enabled, AOT enabled)
OpenJ9   - 0394ef754
OMR      - 582366ae5
JCL      - 3b09cfd7e9 based on jdk-11.0.9+11)

The used OpenJDK versions:

openjdk version "1.8.0_275"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_275-b01)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.275-b01, mixed mode)
openjdk version "9.0.4"
OpenJDK Runtime Environment (build 9.0.4+11)
OpenJDK 64-Bit Server VM (build 9.0.4+11, mixed mode)
openjdk version "11.0.9" 2020-10-20
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9+11)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.9+11, mixed mode)

Summary of the Problem

We made some changes to a class file in the JUnit project, and let several JVMs execute the corresponding JUnit test. We found that in a test case, J9 (1.8.0_275) threw an AssertionError; J9 (11.0.9) threw an ArrayIndexOutOfBoundsException; OpenJDK (8u275, 9.0.4, 11.0.9) and J9 (9.0.4) threw an VerifyError;. The output is shown as follows:

J9 (8u275):

There were 4 failures:
1) errorIsAddedWhenCategoryIsUsedWithBefore(org.junit.experimental.categories.CategoryValidatorTest)
java.lang.AssertionError:
Expected: is <1>
     but: was <20>
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:8)
        at org.junit.experimental.categories.CategoryValidatorTest.testAndAssertErrorMessage(CategoryValidatorTest.java:76)
        at org.junit.experimental.categories.CategoryValidatorTest.errorIsAddedWhenCategoryIsUsedWithBefore(CategoryValidatorTest.java:64)
2) errorIsAddedWhenCategoryIsUsedWithAfter(org.junit.experimental.categories.CategoryValidatorTest)
java.lang.AssertionError:
Expected: is <1>
     but: was <20>
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:8)
        at org.junit.experimental.categories.CategoryValidatorTest.testAndAssertErrorMessage(CategoryValidatorTest.java:76)
        at org.junit.experimental.categories.CategoryValidatorTest.errorIsAddedWhenCategoryIsUsedWithAfter(CategoryValidatorTest.java:70)
3) errorIsAddedWhenCategoryIsUsedWithBeforeClass(org.junit.experimental.categories.CategoryValidatorTest)
java.lang.AssertionError:
Expected: is <1>
     but: was <20>
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:8)
        at org.junit.experimental.categories.CategoryValidatorTest.testAndAssertErrorMessage(CategoryValidatorTest.java:76)
        at org.junit.experimental.categories.CategoryValidatorTest.errorIsAddedWhenCategoryIsUsedWithBeforeClass(CategoryValidatorTest.java:52)
4) errorIsAddedWhenCategoryIsUsedWithAfterClass(org.junit.experimental.categories.CategoryValidatorTest)
java.lang.AssertionError:
Expected: is <1>
     but: was <6>
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:8)
        at org.junit.experimental.categories.CategoryValidatorTest.testAndAssertErrorMessage(CategoryValidatorTest.java:76)
        at org.junit.experimental.categories.CategoryValidatorTest.errorIsAddedWhenCategoryIsUsedWithAfterClass(CategoryValidatorTest.java:58)

FAILURES!!!
Tests run: 5,  Failures: 4

J9 (9.0.4):

There was 1 failure:
1) initializationError(org.junit.experimental.categories.CategoryValidatorTest)
java.lang.VerifyError: JVMVRFY012 stack shape inconsistent; class=org/junit/internal/Checks, method=notNull(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;, pc=88
Exception Details:
  Location:
    org/junit/internal/Checks.notNull(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object; @88: JBaload
  Reason:
    Type top (current frame, locals[5]) is not assignable to 'reference' type
  Current Frame:
    bci: @88
    flags: { }
    locals: { top, 'java/lang/String', integer, integer, integer, top, integer }
    stack: { }
        at org.junit.runners.ParentRunner.<init>(ParentRunner.java:101)
        at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:84)
        at org.junit.runners.JUnit4.<init>(JUnit4.java:23)
        at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:10)
        at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
        at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:37)
        at org.junit.runner.Computer.getRunner(Computer.java:50)
        at org.junit.runner.Computer$1.runnerForClass(Computer.java:31)
        at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
        at org.junit.runners.model.RunnerBuilder.runners(RunnerBuilder.java:125)
        at org.junit.runners.model.RunnerBuilder.runners(RunnerBuilder.java:111)
        at org.junit.runners.Suite.<init>(Suite.java:81)
        at org.junit.runner.Computer$2.<init>(Computer.java:33)
        at org.junit.runner.Computer.getSuite(Computer.java:28)
        at org.junit.runner.Request.classes(Request.java:77)
        at org.junit.runner.JUnitCommandLineParseResult.createRequest(JUnitCommandLineParseResult.java:116)
        at org.junit.runner.JUnitCore.runMain(JUnitCore.java:77)
        at org.junit.runner.JUnitCore.main(JUnitCore.java:36)

FAILURES!!!
Tests run: 1,  Failures: 1

J9 (11.0.9):

There were 4 failures:
1) errorIsAddedWhenCategoryIsUsedWithBefore(org.junit.experimental.categories.CategoryValidatorTest)
java.lang.ArrayIndexOutOfBoundsException
        at java.base/java.util.ArrayList.add(ArrayList.java:487)
        at java.base/java.util.ArrayList.add(ArrayList.java:499)
        at org.junit.experimental.categories.CategoryValidator.addErrorMessage(CategoryValidator.java:60)
        at org.junit.experimental.categories.CategoryValidator.validateAnnotatedMethod(CategoryValidator.java:50)
        at org.junit.experimental.categories.CategoryValidatorTest.testAndAssertErrorMessage(CategoryValidatorTest.java:74)
        at org.junit.experimental.categories.CategoryValidatorTest.errorIsAddedWhenCategoryIsUsedWithBefore(CategoryValidatorTest.java:64)
2) errorIsAddedWhenCategoryIsUsedWithAfter(org.junit.experimental.categories.CategoryValidatorTest)
java.lang.ArrayIndexOutOfBoundsException
        at java.base/java.util.ArrayList.add(ArrayList.java:487)
        at java.base/java.util.ArrayList.add(ArrayList.java:499)
        at org.junit.experimental.categories.CategoryValidator.addErrorMessage(CategoryValidator.java:60)
        at org.junit.experimental.categories.CategoryValidator.validateAnnotatedMethod(CategoryValidator.java:50)
        at org.junit.experimental.categories.CategoryValidatorTest.testAndAssertErrorMessage(CategoryValidatorTest.java:74)
        at org.junit.experimental.categories.CategoryValidatorTest.errorIsAddedWhenCategoryIsUsedWithAfter(CategoryValidatorTest.java:70)
3) errorIsAddedWhenCategoryIsUsedWithBeforeClass(org.junit.experimental.categories.CategoryValidatorTest)
java.lang.ArrayIndexOutOfBoundsException
        at java.base/java.util.ArrayList.add(ArrayList.java:487)
        at java.base/java.util.ArrayList.add(ArrayList.java:499)
        at org.junit.experimental.categories.CategoryValidator.addErrorMessage(CategoryValidator.java:60)
        at org.junit.experimental.categories.CategoryValidator.validateAnnotatedMethod(CategoryValidator.java:50)
        at org.junit.experimental.categories.CategoryValidatorTest.testAndAssertErrorMessage(CategoryValidatorTest.java:74)
        at org.junit.experimental.categories.CategoryValidatorTest.errorIsAddedWhenCategoryIsUsedWithBeforeClass(CategoryValidatorTest.java:52)
4) errorIsAddedWhenCategoryIsUsedWithAfterClass(org.junit.experimental.categories.CategoryValidatorTest)
java.lang.ArrayIndexOutOfBoundsException
        at java.base/java.util.ArrayList.add(ArrayList.java:487)
        at java.base/java.util.ArrayList.add(ArrayList.java:499)
        at org.junit.experimental.categories.CategoryValidator.addErrorMessage(CategoryValidator.java:60)
        at org.junit.experimental.categories.CategoryValidator.validateAnnotatedMethod(CategoryValidator.java:50)
        at org.junit.experimental.categories.CategoryValidatorTest.testAndAssertErrorMessage(CategoryValidatorTest.java:74)
        at org.junit.experimental.categories.CategoryValidatorTest.errorIsAddedWhenCategoryIsUsedWithAfterClass(CategoryValidatorTest.java:58)

FAILURES!!!
Tests run: 5,  Failures: 4

OpenJDK (8u275, 9.0.4, 11.0.9)

There was 1 failure:
1) initializationError(org.junit.experimental.categories.CategoryValidatorTest)
java.lang.VerifyError: (class: org/junit/internal/Checks, method: notNull signature: (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;) Register 5 contains wrong type
        at org.junit.runners.ParentRunner.<init>(ParentRunner.java:101)
        at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:84)
        at org.junit.runners.JUnit4.<init>(JUnit4.java:23)
        at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:10)
        at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
        at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:37)
        at org.junit.runner.Computer.getRunner(Computer.java:50)
        at org.junit.runner.Computer$1.runnerForClass(Computer.java:31)
        at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
        at org.junit.runners.model.RunnerBuilder.runners(RunnerBuilder.java:125)
        at org.junit.runners.model.RunnerBuilder.runners(RunnerBuilder.java:111)
        at org.junit.runners.Suite.<init>(Suite.java:81)
        at org.junit.runner.Computer$2.<init>(Computer.java:33)
        at org.junit.runner.Computer.getSuite(Computer.java:28)
        at org.junit.runner.Request.classes(Request.java:77)
        at org.junit.runner.JUnitCommandLineParseResult.createRequest(JUnitCommandLineParseResult.java:116)
        at org.junit.runner.JUnitCore.runMain(JUnitCore.java:77)
        at org.junit.runner.JUnitCore.main(JUnitCore.java:36)

FAILURES!!!
Tests run: 1,  Failures: 1

Diagnostic files

J9-Discrepancy.zip

Steps to reproduce the behavior:

  1. extract the J9-Discrepancy.zip
  2. In directory J9-Discrepancy, run command java -cp sootOutput/junit-junit/:hamcrest-all-1.3.jar:junit-4.12.jar org.junit.runner.JUnitCore org.junit.experimental.categories.CategoryValidatorTest

Execution environment

  • OS and version: Ubuntu 16.04.6 LTS
  • CPU model: Intel(R) Xeon(R) CPU E5-4610 v4 @ 1.80GHz
  • Number of CPU cores: 4CPUs, each has 10 cores
  • Size of physical memory: 16384 MB * 20
@pshipton
Copy link
Member

@tajila @ChengJin01 fyi

@ChengJin01
Copy link

Will investigate to see what happened to the verifier.

@ChengJin01
Copy link

ChengJin01 commented Jan 21, 2021

It turns out the problem here is the same issue as #11684 which was caused by the fix at #9419 which I already explained the reason in details at #11684 (comment)

The new fix at ChengJin01@dbed590 works good to capture the verification error here (depending the order of the methods to be verified in the code, notNull.(Ljava/lang/Object;)Ljava/lang/Object; should be captured at first.

$ ../jdk11_openj9_fix_v0/bin/java  -cp sootOutput/junit-junit/:hamcrest-all-1.3.jar:junit-4.12.jar 
org.junit.runner.JUnitCore org.junit.experimental.categories.CategoryValidatorTest
JUnit version 4.13

verifyBytecodes: Class.Method.Sig = org/junit/internal/Checks.notNull.(Ljava/lang/Object;)Ljava/lang/Object;, ***** verifyData->errorDetailCode: = 0
.E
Time: 0.011
There was 1 failure:
1) initializationError(org.junit.experimental.categories.CategoryValidatorTest)
java.lang.VerifyError: JVMVRFY012 stack shape inconsistent; class=org/junit/internal/Checks, method=notNull(Ljava/lang/Object;)Ljava/lang/Object;, pc=57
Exception Details:
  Location:
    org/junit/internal/Checks.notNull(Ljava/lang/Object;)Ljava/lang/Object; @57: JBaload1
  Reason:
    Type top (current frame, locals[1]) is not assignable to 'reference' type
  Current Frame:
    bci: @57
    flags: { }
    locals: { 'java/lang/Object', top, integer, integer, integer, integer }
    stack: { }
	at org.junit.runners.ParentRunner.<init>(ParentRunner.java:101)
	at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:84)
	at org.junit.runners.JUnit4.<init>(JUnit4.java:23)
	at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:10)
	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
	at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:37)
	at org.junit.runner.Computer.getRunner(Computer.java:50)
	at org.junit.runner.Computer$1.runnerForClass(Computer.java:31)
	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
	at org.junit.runners.model.RunnerBuilder.runners(RunnerBuilder.java:125)
	at org.junit.runners.model.RunnerBuilder.runners(RunnerBuilder.java:111)
	at org.junit.runners.Suite.<init>(Suite.java:81)
	at org.junit.runner.Computer$2.<init>(Computer.java:33)
	at org.junit.runner.Computer.getSuite(Computer.java:28)
	at org.junit.runner.Request.classes(Request.java:77)
	at org.junit.runner.JUnitCommandLineParseResult.createRequest(JUnitCommandLineParseResult.java:116)
	at org.junit.runner.JUnitCore.runMain(JUnitCore.java:77)
	at org.junit.runner.JUnitCore.main(JUnitCore.java:36)

Will launch personal builds and verify the internal tests to ensure there is no break in the existing test suites.

ChengJin01 pushed a commit to ChengJin01/openj9 that referenced this issue Jan 22, 2021
The change is to reinforce the initial intention that only
a target slot with BCV_SPECIAL_INIT is exempted from being
set with top given setInitializedThisStatus() needs to check
BCV_SPECIAL_INIT to flag the uninitialized_this object.

Fixes: eclipse-openj9#11683,eclipse-openj9#11684,eclipse-openj9#11685

Signed-off-by: Cheng Jin <[email protected]>
@ChengJin01
Copy link

The issue should be closed as the fix at #11753 was merged.

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

Successfully merging a pull request may close this issue.

3 participants