Graal: Compiling scala compiler with native-image yields a NPE

Created on 16 May 2018  路  4Comments  路  Source: oracle/graal

Hello :)

I tried to compile scala compiler (v2.12.6) with native-image and sadly it crashed with a NullPointerException:

$ native-image -cp (echo ./*.jar | tr ' ' ':') scala.tools.nsc.Main
Build on Server(pid: 3083, port: 26682)
   classlist:   2,101.06 ms
       (cap):   1,058.16 ms
       setup:   2,398.98 ms
    analysis:  28,227.79 ms
fatal error: java.lang.NullPointerException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:598)
        at java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:1005)
        at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:398)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:240)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:337)
        at com.oracle.svm.hosted.server.NativeImageBuildServer.executeCompilation(NativeImageBuildServer.java:378)
        at com.oracle.svm.hosted.server.NativeImageBuildServer.lambda$processCommand$8(NativeImageBuildServer.java:315)
        at com.oracle.svm.hosted.server.NativeImageBuildServer.withJVMContext(NativeImageBuildServer.java:396)
        at com.oracle.svm.hosted.server.NativeImageBuildServer.processCommand(NativeImageBuildServer.java:312)
        at com.oracle.svm.hosted.server.NativeImageBuildServer.processRequest(NativeImageBuildServer.java:256)
        at com.oracle.svm.hosted.server.NativeImageBuildServer.lambda$serve$7(NativeImageBuildServer.java:216)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
        at com.oracle.graal.pointsto.ObjectScanner.scanField(ObjectScanner.java:113)
        at com.oracle.graal.pointsto.ObjectScanner.doScan(ObjectScanner.java:263)
        at com.oracle.graal.pointsto.ObjectScanner.finish(ObjectScanner.java:307)
        at com.oracle.graal.pointsto.ObjectScanner.scanBootImageHeapRoots(ObjectScanner.java:78)
        at com.oracle.graal.pointsto.ObjectScanner.scanBootImageHeapRoots(ObjectScanner.java:60)
        at com.oracle.graal.pointsto.BigBang.checkObjectGraph(BigBang.java:581)
        at com.oracle.graal.pointsto.BigBang.finish(BigBang.java:552)
        at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:653)
        at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:381)
        at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
        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: Processing image build request failed

Is this a known problem? I'm using GraalVM 1.0.0-RC1 EE.

native-image

Most helpful comment

Yes, this has been fixed.
There is a few more minor changes that I have on a PR. I will merge them in the next couple of days.
Scala 2.12.6 and 2.13.x will be compiling by the next release. Also, as soon as the merges are in you will be able to use the public version of SVM to build scalac.

All 4 comments

As far as I know @vjovanov works on this. I think it is targeted for 1.0 RC2.

The NPE was reported before and fixed. You can try building from source, but I am not sure if @vjovanov pushed all other changes needed for the scala compiler.

Yes, this has been fixed.
There is a few more minor changes that I have on a PR. I will merge them in the next couple of days.
Scala 2.12.6 and 2.13.x will be compiling by the next release. Also, as soon as the merges are in you will be able to use the public version of SVM to build scalac.

Hi @vjovanov, I tried to do this before going to your ScalaDays talk to see if it would work out of the box. Great talk, amazing results! We're waiting for your PR to be merged and RC2 impatiently :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sxend picture sxend  路  3Comments

helloguo picture helloguo  路  3Comments

himanshumps picture himanshumps  路  3Comments

borkdude picture borkdude  路  3Comments

guaporocco picture guaporocco  路  3Comments