Graal: Regression introduced: IndexOutOfBoundsException creating Micronaut native-image apps

Created on 16 Feb 2019  路  3Comments  路  Source: oracle/graal

Our CI has detected a regression introduced in this commit: https://github.com/oracle/graal/commit/d4558fb51456328dc272aba597882182b1550248

All of our Micronaut Graal test applications fail when building the native image with the following error:

[basic-app:96]    classlist:   9,785.03 ms
[basic-app:96]        (cap):   3,001.95 ms
[basic-app:96]        setup:   6,848.65 ms
[basic-app:96]     analysis:  47,532.28 ms
Fatal error: java.lang.IndexOutOfBoundsException: index 2
    at java.util.concurrent.atomic.AtomicReferenceArray.checkedByteOffset(AtomicReferenceArray.java:78)
    at java.util.concurrent.atomic.AtomicReferenceArray.get(AtomicReferenceArray.java:125)
    at com.oracle.graal.pointsto.flow.context.object.AnalysisObject.getInstanceFieldTypeStore(AnalysisObject.java:213)
    at com.oracle.graal.pointsto.flow.context.object.AnalysisObject.getInstanceFieldFlow(AnalysisObject.java:199)
    at com.oracle.graal.pointsto.flow.LoadFieldTypeFlow$LoadInstanceFieldTypeFlow.onObservedUpdate(LoadFieldTypeFlow.java:159)
    at com.oracle.graal.pointsto.flow.TypeFlow.notifyObservers(TypeFlow.java:347)
    at com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:389)
    at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:508)
    at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:169)
    at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Error: Image building with exit status 1

In this CI execution https://gitlab.com/micronaut-projects/micronaut-graal-tests/pipelines/47754989 you can check that all the applications fail in the "Micronaut" stage. This is the stage we use to build native images with latest GraalVM built from master in the "Build-graal" pipeline stage.

To reproduce the issue you can use any of our test applications used in CI, for example:

  • git clone https://github.com/micronaut-graal-tests/micronaut-basic-app
  • cd micronaut-basic-app/
  • Use GraalVM built from master
  • ./build-native-image.sh
bug native-image

Most helpful comment

Thanks for the quick report! I caught this on our own integration tests too and will have a fix soon.

All 3 comments

Thanks for the quick report! I caught this on our own integration tests too and will have a fix soon.

The issue is fixed in https://github.com/oracle/graal/commit/9f0546754bfb1bf2a1963f0c4358a67aaeab63b1. The problem was with the DynamicHub.getProtectionDomain() substitution: it declared Object return type instead of ProtectionDomain, so the points-to analysis was not applying the expected type narrowing. I also improved the error reporting: instead of an ArrayIndexOutOfBoundException now you would get AnalysisError$FieldNotPresentError: Field java.security.ProtectionDomain.codesource is not present on type java.lang.Object. Error encountered while analysing java.security.ProtectionDomain.getCodeSource().

Thanks! I can confirm that our integration tests pass again :+1:

Was this page helpful?
0 / 5 - 0 ratings