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

Building native image with TruffleRuby and other langs causes ExceptionInInitializerError #7484

Closed
sgammon opened this issue Sep 23, 2023 · 4 comments
Assignees

Comments

@sgammon
Copy link

sgammon commented Sep 23, 2023

Describe the issue
When building Ruby with other languages via native-image, and with PreinitializedContexts set to include ruby, the enclosed exception surfaces (on Oracle GVM latest release). The same exception surfaces at runtime if ruby is not pre-initialized.

Steps to reproduce the issue
Please include both build steps as well as run steps

  1. git clone https://github.com/elide-dev/elide.git && cd elide
  2. Edit the file packages/cli/build.gradle.kts to set enableRuby to true
  3. Run a native build with ./gradlew :packages:cli:nativeCompile

Describe GraalVM and your environment:

  • GraalVM version: Oracle GraalVM 21+35.1 (build 21+35-jvmci-23.1-b15)
  • JDK major version: 21
  • OS: macOS Ventura 13.5.1
  • Architecture: aarch64 (M2)
com.oracle.svm.core.util.VMError$HostedError: java.lang.reflect.InvocationTargetException
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:82)
        at org.graalvm.truffle.runtime.svm/com.oracle.svm.truffle.TruffleBaseFeature.invokeStaticMethod(TruffleBaseFeature.java:274)
        at org.graalvm.truffle.runtime.svm/com.oracle.svm.truffle.TruffleBaseFeature.preInitializeEngine(TruffleBaseFeature.java:509)
        at org.graalvm.truffle.runtime.svm/com.oracle.svm.truffle.TruffleFeature.beforeAnalysis(TruffleFeature.java:436)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$9(NativeImageGenerator.java:774)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:90)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:774)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:593)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:551)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:538)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:720)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.start(NativeImageGeneratorRunner.java:142)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:97)
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at org.graalvm.truffle.runtime.svm/com.oracle.svm.truffle.TruffleBaseFeature.invokeStaticMethod(TruffleBaseFeature.java:272)
        ... 11 more
Caused by: java.lang.ExceptionInInitializerError
        at org.truffleruby.core.symbol.CoreSymbols.createRubySymbol(CoreSymbols.java:213)
        at org.truffleruby.core.symbol.CoreSymbols.createRubySymbol(CoreSymbols.java:224)
        at org.truffleruby.core.symbol.CoreSymbols.<init>(CoreSymbols.java:35)
        at org.truffleruby.RubyLanguage.<init>(RubyLanguage.java:366)
        at org.truffleruby.RubyLanguageProvider.create(RubyLanguageProvider.java:31)
        at org.graalvm.truffle/com.oracle.truffle.api.provider.LanguageProviderSupportImpl.create(LanguageProviderSupportImpl.java:59)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.LanguageCache$ModuleAwareProvider.create(LanguageCache.java:825)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.LanguageCache.loadLanguage(LanguageCache.java:634)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotLanguageInstance.<init>(PolyglotLanguageInstance.java:101)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotLanguage.createInstance(PolyglotLanguage.java:177)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotSharingLayer.allocateInstance(PolyglotSharingLayer.java:413)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotLanguageContext.ensureCreated(PolyglotLanguageContext.java:617)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotLanguageContext.ensureInitialized(PolyglotLanguageContext.java:731)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotContextImpl.getContextInitialized(PolyglotContextImpl.java:735)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotContextImpl.preinitialize(PolyglotContextImpl.java:3600)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotEngineImpl.preInitialize(PolyglotEngineImpl.java:1429)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotImpl.preInitializeEngine(PolyglotImpl.java:421)
        at org.graalvm.polyglot/org.graalvm.polyglot.Engine$ImplHolder.preInitializeEngine(Engine.java:196)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        ... 13 more
Caused by: java.lang.IllegalArgumentException: unknown encoding: "ASCII-8BIT"
        at org.graalvm.truffle/com.oracle.truffle.api.strings.InternalErrors.illegalArgument(InternalErrors.java:76)
        at org.graalvm.truffle/com.oracle.truffle.api.strings.InternalErrors.unknownEncoding(InternalErrors.java:96)
        at org.graalvm.truffle/com.oracle.truffle.api.strings.TruffleString$Encoding.fromJCodingName(TruffleString.java:1089)
        at org.truffleruby.core.encoding.TStringUtils.jcodingToTEncoding(TStringUtils.java:42)
        at org.truffleruby.core.encoding.RubyEncoding.<init>(RubyEncoding.java:57)
        at org.truffleruby.core.encoding.Encodings.initializeRubyEncodings(Encodings.java:82)
        at org.truffleruby.core.encoding.Encodings.<clinit>(Encodings.java:38)
        ... 32 more
@oubidar-Abderrahim
Copy link
Member

Thank you for reporting this, we'll take a look into it shortly

@oubidar-Abderrahim
Copy link
Member

Hi, where do you get TruffleRuby in Oracle GraalVM for JDK21? we no longer provide "gu" with this version, so you cannot install TruffleRuby with it. TruffleRuby can now be obtained either as a standalone distribution or added to your project as a dependency.
I don't see it added in your Gradle setting.
also

versions.java.language = 17
versions.java.minimum = 11
versions.java.target = 17
versions.ecma.language = v5
versions.kotlin.sdk = 1.9.20-Beta2
versions.kotlin.language = 1.9
versions.android.sdk.target = 33 

you're still targeting JDK17 while using JDK21

Could you please share a more detailed steps to reproduce, if there are changes to the code base, please push them to another branch and share that one

@oubidar-Abderrahim
Copy link
Member

Closing this issue for inactivity. if these still relevant, please reopen and provide the required details. Thank you

@sgammon
Copy link
Author

sgammon commented Dec 8, 2023

@oubidar-Abderrahim apologies, I just got your reply from October. It's helpful to tag me because that moves the notification to my Mentions tab (I get a lot of regular issue notifications for Graal)

We've upgraded to GVM 21 latest and I'll see if the error still surfaces.

you're still targeting JDK17 while using JDK21

In some places, we ship libraries which must work at earlier versions of Java (for example, Gradle plugins). Leaf modules target JDK21 and the build is hosted by JDK21.

And, of course, thank you for your help and hard work on Graal!

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