Closed tcollignon closed 2 years ago
This looks like a GraalVM bug to me: the JNI support library should be registering getBytes()
as JNI-reachable but apparently is not doing so.
A workaround could be to define an @AutomaticFeature
to register the String#getBytes()
method for JNI access. See the GraalVM docs for a bit more information.
@galderz or @rsvoboda have you ever encountered this?
Hi Thx for quick reply! @dmlloyd How can I add @AutomaticFeature ? I create JNIRegistrationFeature in my project ?
Hi Thx for quick reply! @dmlloyd How can I add @AutomaticFeature ? I create JNIRegistrationFeature in my project ?
Right. The class name doesn't matter though; you could call it FixTheGraalVMBug
if you wanted to. The important part is the annotation on the class, and overriding the beforeAnalysis
method of the Feature
interface to register the missing method.
Nope, I haven't seen this (yet). I'm not on native lately.
@tcollignon is it RHEL 7 specific? And did you experience this with prior versions of Quarkus/GraalVM?
I've opened https://github.com/oracle/graal/pull/2673 to have this fixed long term in Graal VM.
Hi @rsvoboda
I have only test on RHEL on Linux Side, and on Windows it works fine (I have GraalVM 20.2-dev and windows 10)
With prior version of QUarkus/GraalVM it was working fine on other project that I have and now it doesn't working with same error
Thx @jaikiran for the PR in GraalVM
I try to add theses things in my project, but now I run into this problem : https://github.com/quarkusio/quarkus/issues/10498
java.lang.RuntimeException:
java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.deployment.steps.BootstrapConfigSetupBuildStep#setupBootstrapConfig threw an exception: java.lang.IllegalArgumentException: Unsupported api 524288
at org.objectweb.asm.ClassVisitor.<init>(ClassVisitor.java:70)
at io.quarkus.gizmo.GizmoClassVisitor.<init>(GizmoClassVisitor.java:22)
at io.quarkus.gizmo.ClassCreator.writeTo(ClassCreator.java:150)
at io.quarkus.gizmo.ClassCreator.close(ClassCreator.java:203)
at io.quarkus.deployment.steps.BootstrapConfigSetupBuildStep.setupBootstrapConfig(BootstrapConfigSetupBuildStep.java:40)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:932)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
at java.base/java.lang.Thread.run(Thread.java:834)
at org.jboss.threads.JBossThread.run(JBossThread.java:479)
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>svm</artifactId>
<version>19.3.2</version>
</dependency>
import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.jni.JNIRuntimeAccess; import org.graalvm.nativeimage.hosted.Feature;
@AutomaticFeature
public class JNIRegistrationFeature implements Feature {
public void beforeAnalysis(BeforeAnalysisAccess access) {
try {
JNIRuntimeAccess.register(String.class);
JNIRuntimeAccess.register(String.class.getDeclaredMethod("getBytes"));
} catch (NoSuchMethodException e) {
}
}
}
and on Windows it works fine
That specific code path in the exception is only applicable for Linux systems. So it's understandable why it won't show up in Windows. Having said that, a call to new FileInputStream
is such a common occurence that I am surprised this hasn't shown up previously and I'm wondering if there's something more going on here. On the RHEL setup where you are running into this issue, can you tell us what the output of the following command is:
ls -lh /sys/fs/cgroup/memory/memory.limit_in_bytes
As for the other issue (related to ASM) that you ran into while using the workaround, I don't have a solution for that unfortunately. That needs to be fixed in Graal VM (they have fixed it but no released version has that fix yet).
Hi @jaikiran
this is the output :
14:59:57 + ls -lh /sys/fs/cgroup/memory/memory.limit_in_bytes
14:59:57 -rw-r--r-- 1 root root 0 15 juil. 14:59 /sys/fs/cgroup/memory/memory.limit_in_bytes
Well, that rules out the case that the code might be going into a "not so common" code path where the file isn't existent. I can't really think of why this issue hasn't shown up previously and why no one else seems to be running into this.
@tcollignon, I gave this a try on a RHEL7 setup, JDK 11.0.7 with a simple application like you noted. I haven't been able to reproduce this issue. Are you still running into this issue? If so, any chance you can share the actual application as a github repo perhaps?
Hi @jaikiran
Yes I still running this issue, I wait for https://github.com/quarkusio/quarkus/issues/10498 (If anyone knows if there is maven snapshot dependency of org.graalvm.nativeimage:svm ? )
I can share the code if you want, but it's a quarkus basic hello world
I can share the code if you want, but it's a quarkus basic hello world
Yes, please. Given that I couldn't reproduce this with a simple Quarkus application, I would like to rule out any other possibilities.
I have add this here : https://github.com/tcollignon/example-quarkus-10682
More of a FYI, this issue got reported again in Quarkus and it is now fixed in Graal VM itself https://github.com/oracle/graal/pull/2673.
Hi
On a project without resteasy the hack : A workaround could be to define an @AutomaticFeature to register the String#getBytes() method for JNI access Works for me now with graalvm 20.2
But on a project with resteasy it does not, I have this error (in a docker container) :
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2020-11-17 16:56:33,681 ERROR [io.qua.run.Application] (main) Failed to start application (with profile prod): java.lang.NoSuchMethodError: java.lang.String.<init>([B)V
at com.oracle.svm.jni.functions.JNIFunctions$Support.getMethodID(JNIFunctions.java:1103)
at com.oracle.svm.jni.functions.JNIFunctions$Support.getMethodID(JNIFunctions.java:1088)
at com.oracle.svm.jni.functions.JNIFunctions.GetMethodID(JNIFunctions.java:391)
at java.io.UnixFileSystem.canonicalize0(UnixFileSystem.java)
at java.io.UnixFileSystem.canonicalize(UnixFileSystem.java:178)
at java.io.File.getCanonicalPath(File.java:620)
at java.io.File.getCanonicalFile(File.java:645)
at sun.security.provider.FileInputStreamPool.getInputStream(FileInputStreamPool.java:84)
at sun.security.provider.NativePRNG$RandomIO.<init>(NativePRNG.java:388)
at sun.security.provider.NativePRNG$1.run(NativePRNG.java:190)
at sun.security.provider.NativePRNG$1.run(NativePRNG.java:130)
at java.security.AccessController.doPrivileged(AccessController.java:83)
at sun.security.provider.NativePRNG.initIO(NativePRNG.java:129)
at sun.security.provider.NativePRNG.<clinit>(NativePRNG.java:93)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:351)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:271)
at java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at java.security.Provider.newInstanceUtil(Provider.java:176)
at java.security.Provider$Service.newInstance(Provider.java:1891)
at java.security.SecureRandom.getDefaultPRNG(SecureRandom.java:290)
at java.security.SecureRandom.<init>(SecureRandom.java:219)
at java.util.UUID$Holder.<clinit>(UUID.java:101)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:351)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:271)
at java.util.UUID.randomUUID(UUID.java:147)
at io.vertx.core.file.impl.FileResolver.setupCacheDir(FileResolver.java:385)
at io.vertx.core.file.impl.FileResolver.<init>(FileResolver.java:119)
at io.vertx.core.impl.VertxImpl.<init>(VertxImpl.java:167)
at io.vertx.core.impl.VertxImpl.vertx(VertxImpl.java:92)
at io.vertx.core.impl.VertxFactoryImpl.vertx(VertxFactoryImpl.java:40)
at io.vertx.core.impl.VertxFactoryImpl.vertx(VertxFactoryImpl.java:32)
at io.vertx.core.Vertx.vertx(Vertx.java:85)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder.initialize(VertxCoreRecorder.java:196)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$VertxSupplier.get(VertxCoreRecorder.java:390)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$VertxSupplier.get(VertxCoreRecorder.java:377)
at io.quarkus.resteasy.runtime.standalone.ResteasyStandaloneRecorder.vertxRequestHandler(ResteasyStandaloneRecorder.java:92)
at io.quarkus.deployment.steps.ResteasyStandaloneBuildStep$boot-614950547.deploy_0(ResteasyStandaloneBuildStep$boot-614950547.zig:103)
at io.quarkus.deployment.steps.ResteasyStandaloneBuildStep$boot-614950547.deploy(ResteasyStandaloneBuildStep$boot-614950547.zig:40)
at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:499)
at io.quarkus.runtime.Application.start(Application.java:90)
at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:95)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:62)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:38)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:104)
at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
@tcollignon Have you tried with Mandrel or GraalVM 20.3?
For the record, I know we register String
for reflection at least in one of our extensions.
If it's a common issue, we might have to do it in the core extension.
Hello @tcollignon,
But on a project with resteasy it does not, I have this error (in a docker container) :
2020-11-17 16:56:33,681 ERROR [io.qua.run.Application] (main) Failed to start application (with profile prod):
java.lang.NoSuchMethodError: java.lang.String.<init>([B)V
at com.oracle.svm.jni.functions.JNIFunctions$Support.getMethodID(JNIFunctions.java:1103)
at com.oracle.svm.jni.functions.JNIFunctions$Support.getMethodID(JNIFunctions.java:1088)
at com.oracle.svm.jni.functions.JNIFunctions.GetMethodID(JNIFunctions.java:391)
at java.io.UnixFileSystem.canonicalize0(UnixFileSystem.java)
at java.io.UnixFileSystem.canonicalize(UnixFileSystem.java:178)
at java.io.File.getCanonicalPath(File.java:620)
at java.io.File.getCanonicalFile(File.java:645)
This is a different error and in fact a new bug. It looks like the java.lang.String
constructor which takes (only) a byte[]
is being invoked from JNI and that constructor isn't enrolled for JNI access in GraalVM and hence this error. I had a look at the JNI code of the JDK and I don't see any reference to this constructor. All references go through the java.lang.String
constructor which takes a byte[]
and a String
encoding params. I'm really surprised that you are consistently hitting issues like these on your setup and it makes me wonder what vendor/version of the JVM is being picked up.
Is there any more details you could add that might help us fix this? The fix itself is a simple one liner change that we can do in GraalVM itself. However, I still don't see how you end up running into this issue and that doesn't give me the confidence to propose the fix.
Hi,
I have upgrade to GraalVM 21.0.0 and quarkus 1.13.3, and now I have a new error
java.lang.InternalError: java.lang.reflect.InvocationTargetException
at com.oracle.svm.core.containers.Metrics.systemMetrics(Metrics.java:66)
at com.oracle.svm.core.containers.Container.metrics(Container.java:44)
at com.oracle.svm.core.ContainerInfo.<init>(ContainerInfo.java:34)
at com.oracle.svm.core.Containers.memoryLimitInBytes(Containers.java:162)
at com.oracle.svm.core.heap.PhysicalMemory.doInitialize(PhysicalMemory.java:144)
at com.oracle.svm.core.heap.PhysicalMemory.tryInitialize(PhysicalMemory.java:114)
at com.oracle.svm.core.genscavenge.HeapPolicy.samplePhysicalMemorySize(HeapPolicy.java:351)
at com.oracle.svm.core.genscavenge.ThreadLocalAllocation.runSlowPathHooks(ThreadLocalAllocation.java:156)
at com.oracle.svm.core.genscavenge.ThreadLocalAllocation.slowPathNewArray(ThreadLocalAllocation.java:194)
at java.util.Arrays.copyOfRange(Arrays.java:4027)
at java.lang.StringLatin1.newString(StringLatin1.java:715)
at java.lang.String.substring(String.java:1846)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.setNativeName(PosixJavaThreads.java:153)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.beforeThreadRun(PosixJavaThreads.java:201)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:507)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
@tcollignon At first glance, that would appear to a different issue altogether. Mind creating a new one along with a reproducer or an updated reproducer?
Hello @tcollignon,
But on a project with resteasy it does not, I have this error (in a docker container) : 2020-11-17 16:56:33,681 ERROR [io.qua.run.Application] (main) Failed to start application (with profile prod): java.lang.NoSuchMethodError: java.lang.String.<init>([B)V at com.oracle.svm.jni.functions.JNIFunctions$Support.getMethodID(JNIFunctions.java:1103) at com.oracle.svm.jni.functions.JNIFunctions$Support.getMethodID(JNIFunctions.java:1088) at com.oracle.svm.jni.functions.JNIFunctions.GetMethodID(JNIFunctions.java:391) at java.io.UnixFileSystem.canonicalize0(UnixFileSystem.java) at java.io.UnixFileSystem.canonicalize(UnixFileSystem.java:178) at java.io.File.getCanonicalPath(File.java:620) at java.io.File.getCanonicalFile(File.java:645)
This one should now be fixed by this PR https://github.com/oracle/graal/pull/3680
This is pretty old and likely not an issue anymore, so I'll close it.
If it's still a problem, feel free to comment
Describe the bug I create a new quarkus 1.6.0.Final project with nothing special (only quarkus-rest-client and no code) Java 11.0.3 If I run on Linux RHEL 7 and GraalVM and I got this error :
java.lang.NoSuchMethodError: java.lang.String.getBytes()[B
Expected behavior I should run it without error (In a bigger usecase I have picocli and small amount of code, but to test I delete all the code and picocli extension and get same error)
Actual behavior If I run with GraalVM 19.3.2 I got :
I I run with GraalVM 20.1.0 I got this
To Reproduce Steps to reproduce the behavior:
Configuration Nothing in configuration file
Environment (please complete the following information):
uname -a
orver
:Linux d6eb2f26d7d0 3.10.0-862.14.4.el7.x86_64 #1 SMP Fri Sep 21 09:07:21 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
java -version
:If this can be the problem ?
This is the same with
I got this trace during native compilation :
mvnw --version
orgradlew --version
): mvn 3.6.2 (same with 3.6.3)