Skip to content

Error when building a native image VMError$HostedError: should not reach here #811

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

Closed
nhenneaux opened this issue Nov 16, 2018 · 5 comments
Assignees

Comments

@nhenneaux
Copy link

nhenneaux commented Nov 16, 2018

When I try to build a native image from a service fat jar (basically a Jetty servier with JAX-RS plus CDI) I get the following error.

$ ./bin/native-image -jar service-fatjar.jar 
Build on Server(pid: 30177, port: 63160)*
[service-fatjar.jar :30177]    classlist:   6,939.70 ms
[service-fatjar.jar :30177]        (cap):     254.83 ms
[service-fatjar.jar :30177]        setup:   5,614.94 ms
fatal error: com.oracle.svm.core.util.VMError$HostedError: should not reach here
	at com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:62)
	at com.oracle.svm.hosted.c.BuiltinDirectives.getHeaderFiles(BuiltinDirectives.java:37)
	at com.oracle.svm.hosted.c.CAnnotationProcessor.reportCompilerError(CAnnotationProcessor.java:136)
	at com.oracle.svm.hosted.c.codegen.CCompilerInvoker.compileAndParseError(CCompilerInvoker.java:74)
	at com.oracle.svm.hosted.c.CAnnotationProcessor.compileQueryCode(CAnnotationProcessor.java:131)
	at com.oracle.svm.hosted.c.CAnnotationProcessor.process(CAnnotationProcessor.java:84)
	at com.oracle.svm.hosted.c.NativeLibraries.finish(NativeLibraries.java:346)
	at com.oracle.svm.hosted.NativeImageGenerator.processNativeLibraryImports(NativeImageGenerator.java:1345)
	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:550)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:402)
	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

I'm running MacOS

$ uname -a
Darwin Nicolass-MacBook-Pro-2.local 18.2.0 Darwin Kernel Version 18.2.0: Fri Oct  5 19:41:49 PDT 2018; root:xnu-4903.221.2~2/RELEASE_X86_64 x86_64

Using latest Graal RC

$ ./bin/java -version
openjdk version "1.8.0_192"
OpenJDK Runtime Environment (build 1.8.0_192-20181024123616.buildslave.jdk8u-src-tar--b12)
GraalVM 1.0.0-rc9 (build 25.192-b12-jvmci-0.49, mixed mode)

The fat jar is built using Maven and Java 8.

$ mvn -version
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T20:41:47+02:00)
Maven home: /usr/local/Cellar/maven/3.6.0/libexec
Java version: 1.8.0_181, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/jre
Default locale: en_BE, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.1", arch: "x86_64", family: "mac"
@nhenneaux nhenneaux changed the title Error when building a native image Error when building a native image VMError$HostedError: should not reach here Nov 16, 2018
@nhenneaux
Copy link
Author

Could be related to issue #518? How can I confirm that?

@peter-hofer
Copy link
Member

This appears to be a different problem than #518. While building a native image, we generate, compile and run C code to determine the values of various constants, sizes of structs, etc. In your case, the compilation of this generated code fails, and while trying to report this error, another error occurs -- which is probably connected to the original error. Are you by any chance using any of org.graalvm.nativeimage.c (@CFunction, @CStruct, @CConstant, ...)? If so, these need an enclosing @CContext annotation. Please report back if that is the problem, because then we should have a proper error message in that case.

@nhenneaux
Copy link
Author

As far as I know I don't use such annotation org.graalvm.nativeimage.c perhaps in a dependency library but I don't think so. Here is the list of dependencies, perhaps you know if some are using such annotation?

|  \- org.ehcache.modules:ehcache-impl:jar:3.5.2:compile
|     +- org.ehcache.modules:ehcache-api:jar:3.5.2:compile
|     +- org.ehcache.modules:ehcache-core:jar:3.5.2:compile
|     |  \- org.terracotta:statistics:jar:2.0.5:compile
|     +- org.terracotta:offheap-store:jar:2.4.0:compile
|     \- org.ehcache:sizeof:jar:0.3.0:compile
+- org.glassfish.jersey.ext.cdi:jersey-weld2-se:jar:2.27:compile
|  +- org.glassfish.jersey.core:jersey-server:jar:2.27:compile
|  |  \- org.glassfish.jersey.media:jersey-media-jaxb:jar:2.27:compile
|  |     \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:compile
|  +- org.glassfish.jersey.ext.cdi:jersey-cdi1x:jar:2.27:compile
|  \- javax.ws.rs:javax.ws.rs-api:jar:2.1:compile
+- org.eclipse.jetty:jetty-servlet:jar:9.4.12.v20180830:compile
|  \- org.eclipse.jetty:jetty-security:jar:9.4.12.v20180830:compile
+- org.glassfish.jersey.containers:jersey-container-servlet-core:jar:2.27:compile
|  \- org.glassfish.jersey.core:jersey-common:jar:2.27:compile
+- org.glassfish.jersey.ext:jersey-proxy-client:jar:2.27:compile
+- org.glassfish.jersey.inject:jersey-hk2:jar:2.27:compile
|  \- org.glassfish.hk2:hk2-locator:jar:2.5.0-b42:compile
|     +- org.glassfish.hk2.external:aopalliance-repackaged:jar:2.5.0-b42:compile
|     +- org.glassfish.hk2:hk2-api:jar:2.5.0-b42:compile
|     +- org.glassfish.hk2:hk2-utils:jar:2.5.0-b42:compile
|     \- org.javassist:javassist:jar:3.22.0-CR2:compile
+- org.glassfish.jersey.ext:jersey-bean-validation:jar:2.27:compile
+- org.hibernate.validator:hibernate-validator:jar:6.0.13.Final:compile
|  +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
|  \- com.fasterxml:classmate:jar:1.3.4:compile
+- org.glassfish.jersey.media:jersey-media-multipart:jar:2.27:compile
|  \- org.jvnet.mimepull:mimepull:jar:1.9.6:compile
+- org.glassfish:javax.el:jar:3.0.0:compile
+- org.eclipse.jetty.http2:http2-server:jar:9.4.12.v20180830:compile
|  \- org.eclipse.jetty.http2:http2-common:jar:9.4.12.v20180830:compile
|     \- org.eclipse.jetty.http2:http2-hpack:jar:9.4.12.v20180830:compile
+- org.eclipse.jetty:jetty-alpn-server:jar:9.4.12.v20180830:compile
+- org.eclipse.jetty:jetty-alpn-java-server:jar:9.4.12.v20180830:compile
|  +- org.eclipse.jetty:jetty-io:jar:9.4.12.v20180830:compile
|  \- org.eclipse.jetty.alpn:alpn-api:jar:1.1.3.v20160715:compile
+- org.eclipse.jetty:jetty-alpn-java-client:jar:9.4.12.v20180830:compile
|  \- org.eclipse.jetty:jetty-alpn-client:jar:9.4.12.v20180830:compile
+- org.eclipse.jetty:jetty-alpn-openjdk8-server:jar:9.4.12.v20180830:compile
+- org.eclipse.jetty:jetty-alpn-openjdk8-client:jar:9.4.12.v20180830:compile
+- org.glassfish.jersey.connectors:jersey-jetty-connector:jar:2.27:compile
|  \- org.glassfish.jersey.core:jersey-client:jar:2.27:compile
+- org.eclipse.jetty.http2:http2-http-client-transport:jar:9.4.12.v20180830:compile
|  \- org.eclipse.jetty.http2:http2-client:jar:9.4.12.v20180830:compile
+- org.eclipse.jetty:jetty-client:jar:9.4.12.v20180830:compile
|  \- org.eclipse.jetty:jetty-http:jar:9.4.12.v20180830:compile
+- org.eclipse.jetty:jetty-server:jar:9.4.12.v20180830:compile
|  \- javax.servlet:javax.servlet-api:jar:3.1.0:compile
+- org.eclipse.jetty:jetty-util:jar:9.4.12.v20180830:compile
+- org.eclipse.jetty:jetty-continuation:jar:9.4.12.v20180830:compile
+- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.9.7:compile
|  +- com.fasterxml.jackson.core:jackson-core:jar:2.9.7:compile
|  \- com.fasterxml.jackson.core:jackson-databind:jar:2.9.7:compile
+- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.9.7:compile
|  \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.9.7:compile
+- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.7:compile
+- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.9.7:compile
|  \- org.yaml:snakeyaml:jar:1.23:compile
+- io.swagger:swagger-jersey2-jaxrs:jar:1.5.18:compile
|  \- io.swagger:swagger-jaxrs:jar:1.5.18:compile
|     +- io.swagger:swagger-core:jar:1.5.18:compile
|     |  +- org.apache.commons:commons-lang3:jar:3.2.1:compile
|     |  \- io.swagger:swagger-models:jar:1.5.18:compile
|     +- org.reflections:reflections:jar:0.9.11:compile
|     \- com.google.guava:guava:jar:25.1-jre:compile
|        +- org.checkerframework:checker-qual:jar:2.0.0:compile
|        +- com.google.errorprone:error_prone_annotations:jar:2.1.3:compile
|        +- com.google.j2objc:j2objc-annotations:jar:1.1:compile
|        \- org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:compile
|  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.7:compile
|  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.7:compile
+- javax.validation:validation-api:jar:2.0.0.Final:compile
+- io.swagger:swagger-annotations:jar:1.5.18:compile
+- org.slf4j:slf4j-api:jar:1.7.25:compile
+- javax.annotation:javax.annotation-api:jar:1.3.2:compile
+- javax.activation:javax.activation-api:jar:1.2.0:compile
+- javax.xml.bind:jaxb-api:jar:2.3.0:compile
\- org.glassfish.jaxb:jaxb-runtime:jar:2.3.0:compile
   +- org.glassfish.jaxb:jaxb-core:jar:2.3.0:compile
   |  +- org.glassfish.jaxb:txw2:jar:2.3.0:compile
   |  \- com.sun.istack:istack-commons-runtime:jar:3.0.5:compile
   +- org.jvnet.staxex:stax-ex:jar:1.7.8:compile
   \- com.sun.xml.fastinfoset:FastInfoset:jar:1.2.13:compile
\- org.jboss.weld.se:weld-se-core:jar:3.0.5.Final:compile
   +- org.jboss.weld.environment:weld-environment-common:jar:3.0.5.Final:compile
   |  \- org.jboss.weld:weld-core-impl:jar:3.0.5.Final:compile
   |     +- org.jboss.weld:weld-api:jar:3.0.SP4:compile
   |     +- org.jboss.weld:weld-spi:jar:3.0.SP4:compile
   |     \- org.jboss.spec.javax.interceptor:jboss-interceptors-api_1.2_spec:jar:1.0.0.Final:compile
   +- org.jboss.weld.probe:weld-probe-core:jar:3.0.5.Final:compile
   \- org.jboss.classfilewriter:jboss-classfilewriter:jar:1.2.3.Final:compile
\- javax.enterprise:cdi-api:jar:2.0.SP1:compile
   \- javax.inject:javax.inject:jar:1:compile
+- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.11.1:compile
|  \- org.apache.logging.log4j:log4j-api:jar:2.11.1:compile
\- org.apache.logging.log4j:log4j-core:jar:2.11.1:compile
com.google.code.findbugs:annotations:jar:3.0.1u2:provided
+- net.jcip:jcip-annotations:jar:1.0:provided
\- com.google.code.findbugs:jsr305:jar:3.0.1:compile

@peter-hofer
Copy link
Member

I don't think so. In that case, this is a bug triggered by a compiler error. I'll remove the questionable call to shouldNotReachHere(). Then you should see the original compiler error -- probably missing libraries or header files on your computer.

dougxc pushed a commit that referenced this issue Dec 3, 2018
@peter-hofer
Copy link
Member

I have removed the call to shouldNotReachHere so that the C compiler error should now be correctly reported.

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

No branches or pull requests

3 participants