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

Error encountered while parsing org.graalvm.compiler.hotspot.HotSpotBackend.mulAddStub #1235

Closed
ilopmar opened this issue May 3, 2019 · 5 comments
Assignees

Comments

@ilopmar
Copy link

ilopmar commented May 3, 2019

After #1194 is fixed I can use the agent to generate the meta-information needed to build the native image. I used that for the test application in that issue, then include the generated files in the application jar and tried to build the native image. It fails with the error shown.

To reproduce the issue:

  • git clone https://github.com/micronaut-graal-tests/micronaut-hibernate-graal
  • cd micronaut-hibernate-graal
  • git checkout graal-rc17
  • Use Graal from master branch (currently rc18-dev)
  • ./build-native-image.sh

Error:

[hibernate-graal:27659]    classlist:  12,266.70 ms
[hibernate-graal:27659]        (cap):   1,470.59 ms
[hibernate-graal:27659]        setup:   3,906.91 ms
[hibernate-graal:27659]     analysis:  39,731.96 ms
Error: Error encountered while parsing org.graalvm.compiler.hotspot.replacements.ObjectSubstitutions.fastNotifyStub(org.graalvm.compiler.core.common.spi.ForeignCallDescriptor, java.lang.Object) 
Parsing context:
	parsing com.oracle.svm.reflect.ObjectSubstitutions_fastNotifyStub_8860046562fe1ab7ebba5ac3f7053dde03877841_319.invoke(Unknown Source)
	parsing java.lang.reflect.Method.invoke(Method.java:498)
	parsing ch.qos.logback.classic.spi.ThrowableProxy.<init>(ThrowableProxy.java:66)
	parsing ch.qos.logback.classic.spi.LoggingEvent.<init>(LoggingEvent.java:119)
	parsing ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:419)
	parsing ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:383)
	parsing ch.qos.logback.classic.Logger.error(Logger.java:538)
	parsing io.micronaut.runtime.Micronaut.handleStartupException(Micronaut.java:304)
	parsing io.micronaut.runtime.Micronaut.start(Micronaut.java:155)
	parsing io.micronaut.runtime.Micronaut.run(Micronaut.java:288)
	parsing io.micronaut.runtime.Micronaut.run(Micronaut.java:274)
	parsing example.micronaut.Application.main(Application.java:8)
	parsing com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:153)
	parsing com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0)

Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Error: Error encountered while parsing org.graalvm.compiler.hotspot.replacements.ObjectSubstitutions.fastNotifyStub(org.graalvm.compiler.core.common.spi.ForeignCallDescriptor, java.lang.Object) 
Parsing context:
	parsing org.graalvm.compiler.hotspot.replacements.ObjectSubstitutions.notify(ObjectSubstitutions.java:50)
	parsing com.oracle.svm.reflect.ObjectSubstitutions_notify_10505ce470b44c4d5a9d72f0c69c5deb5b4dcb28_317.invoke(Unknown Source)
	parsing java.lang.reflect.Method.invoke(Method.java:498)
	parsing ch.qos.logback.classic.spi.ThrowableProxy.<init>(ThrowableProxy.java:66)
	parsing ch.qos.logback.classic.spi.LoggingEvent.<init>(LoggingEvent.java:119)
	parsing ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:419)
	parsing ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:383)
	parsing ch.qos.logback.classic.Logger.error(Logger.java:538)
	parsing io.micronaut.runtime.Micronaut.handleStartupException(Micronaut.java:304)
	parsing io.micronaut.runtime.Micronaut.start(Micronaut.java:155)
	parsing io.micronaut.runtime.Micronaut.run(Micronaut.java:288)
	parsing io.micronaut.runtime.Micronaut.run(Micronaut.java:274)
	parsing example.micronaut.Application.main(Application.java:8)
	parsing com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:153)
	parsing com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0)
@cstancu
Copy link
Member

cstancu commented May 3, 2019

The problem that you are seeing is because the reflect-config.json file contains entries for org.graalvm.compiler.*. This is a side effect of the fact that the Graal compiler itself is Java code that the agent cannot dissambiguate. The fix for this is to use libgraal instead, i.e., the Graal compiler built as a native shared library. If you use an official GraalVM distribution starting with RC15 then that is the default. If however you build a GraalVM distribution from source then you currently need to additionally specify LIBGRAAL=true, e.g. for a minimal distribution that contains native-image:

$ LIBGRAAL=true mx --disable-polyglot --disable-libpolyglot --dynamicimports /substratevm build

or

$ cat env 
DISABLE_POLYGLOT=true
DISABLE_LIBPOLYGLOT=true
DYNAMIC_IMPORTS=/substratevm
LIBGRAAL=true
$ mx --env ../env build

You should see a Building libjvmcicompiler.so.image... step. To double check that the GraalVM distribution is using libgraal you can try running ${GRAALVM_HOME}/bin/java -XX:+UseJVMCINativeLibrary. This will fail if it can’t find and load libjvmcicompiler.so.

@cstancu
Copy link
Member

cstancu commented May 3, 2019

However, after eliminating the org.graalvm.compiler.* entries from your reflection config you will likely run into Error: Field java.lang.reflect.Method.defaultValue is not present on type java.lang.reflect.Constructor. Error encountered while analysing java.lang.reflect.Method.getDefaultValue() . A fix for that will be pushed soon.

@ilopmar
Copy link
Author

ilopmar commented May 6, 2019

Thanks for the detailed explanation. Now, as you mentioned I run into that error. I'll wait until it's fixed to try again.

@cstancu
Copy link
Member

cstancu commented May 7, 2019

The Error: Field java.lang.reflect.Method.defaultValue is not present on type java.lang.reflect.Constructor is fixed by c6237d2.

@cstancu cstancu closed this as completed May 7, 2019
@cstancu
Copy link
Member

cstancu commented May 7, 2019

However, now you'll see a series of No instances are allowed in the image heap for a class that is initialized or reinitialized at image runtime: ... which will require further configuration. I haven't investigated it further.

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

2 participants