Skip to content

Conversation

@graalvmbot
Copy link
Collaborator

@graalvmbot graalvmbot commented Dec 16, 2024

SharedBytecodeParser#maybeEagerlyResolve(int, int) swallows certain exceptions in the expectation that the exception being swallowed will be re-thrown anyway in a subsequent step. However, this is not always the case. To mitigate loss of exception causality in this scenario, the swallowed exception should be saved so that it can be included when reporting an unresolved element.

The result of this PR is best shown with this diff:

commit 7d30893ce836d42a3d237f2cb625b5d4b22856a0
Author: Doug Simon <doug.simon@oracle.com>
Date:   Sun Dec 15 13:46:14 2024 +0100

    tmp: after stack trace

diff --git a/substratevm/stack_trace.txt b/substratevm/stack_trace.txt
index b57ce4ae697..0bf7824398a 100644
--- a/substratevm/stack_trace.txt
+++ b/substratevm/stack_trace.txt
@@ -1,5 +1,5 @@
 Error: Discovered unresolved type during parsing: jdk.graal.compiler.word.WordFactory. This error is reported at image build time because class com.oracle.svm.enterprise.interpreter.metadata.serialization.Serializers is registered for linking at image build time by system default.
-Error encountered while parsing com.oracle.svm.enterprise.interpreter.metadata.serialization.Serializers$$Lambda/0x0000400001c8f020.read(Unknown Source)
+Error encountered while parsing com.oracle.svm.enterprise.interpreter.metadata.serialization.Serializers$$Lambda/0x0000030001cb1c70.read(Unknown Source)
 Parsing context:
    at com.oracle.svm.enterprise.interpreter.metadata.serialization.SerializationContext$Reader.readValue(SerializationContext.java:37)
    at com.oracle.svm.enterprise.interpreter.metadata.InterpreterUniverseImpl.loadFrom(InterpreterUniverseImpl.java:233)
@@ -9,7 +9,7 @@ Parsing context:
 Detailed message:
 
 Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Discovered unresolved type during parsing: jdk.graal.compiler.word.WordFactory. This error is reported at image build time because class com.oracle.svm.enterprise.interpreter.metadata.serialization.Serializers is registered for linking at image build time by system default.
-Error encountered while parsing com.oracle.svm.enterprise.interpreter.metadata.serialization.Serializers$$Lambda/0x0000400001c8f020.read(Unknown Source)
+Error encountered while parsing com.oracle.svm.enterprise.interpreter.metadata.serialization.Serializers$$Lambda/0x0000030001cb1c70.read(Unknown Source)
 Parsing context:
    at com.oracle.svm.enterprise.interpreter.metadata.serialization.SerializationContext$Reader.readValue(SerializationContext.java:37)
    at com.oracle.svm.enterprise.interpreter.metadata.InterpreterUniverseImpl.loadFrom(InterpreterUniverseImpl.java:233)
@@ -71,7 +71,8 @@ Caused by: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Dis
 	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureFlowsGraphCreated(MethodTypeFlow.java:152)
 	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.getOrCreateMethodFlowsGraphInfo(MethodTypeFlow.java:110)
 	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.typestate.DefaultVirtualInvokeTypeFlow.onObservedUpdate(DefaultVirtualInvokeTypeFlow.java:119)
-	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.TypeFlow.lambda$addObserver$0(TypeFlow.java:710)
+	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:870)
+	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.PointsToAnalysis$1.run(PointsToAnalysis.java:600)
 	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:166)
 	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:152)
 	at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1735)
@@ -81,3 +82,19 @@ Caused by: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Dis
 	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1394)
 	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1970)
 	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)
+Caused by: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Error loading a referenced type: java.lang.IllegalAccessError: class com.oracle.svm.enterprise.interpreter.metadata.serialization.Serializers (in module com.oracle.svm.enterprise.jdwp.common) cannot access class jdk.graal.compiler.word.WordFactory (in module jdk.graal.compiler) because module jdk.graal.compiler does not export jdk.graal.compiler.word to module com.oracle.svm.enterprise.jdwp.common
+	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.infrastructure.WrappedConstantPool.loadReferencedType(WrappedConstantPool.java:98)
+	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.infrastructure.WrappedConstantPool.loadReferencedType(WrappedConstantPool.java:104)
+	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SubstrateClassInitializationPlugin.loadReferencedType(SubstrateClassInitializationPlugin.java:58)
+	at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.loadReferenceType(BytecodeParser.java:4761)
+	at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.maybeEagerlyResolve(BytecodeParser.java:4743)
+	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.maybeEagerlyResolve(SharedGraphBuilderPhase.java:289)
+	at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.lookupMethod(BytecodeParser.java:4679)
+	at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.genInvokeStatic(BytecodeParser.java:1841)
+	... 48 more
+Caused by: java.lang.IllegalAccessError: class com.oracle.svm.enterprise.interpreter.metadata.serialization.Serializers (in module com.oracle.svm.enterprise.jdwp.common) cannot access class jdk.graal.compiler.word.WordFactory (in module jdk.graal.compiler) because module jdk.graal.compiler does not export jdk.graal.compiler.word to module com.oracle.svm.enterprise.jdwp.common
+	at jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVM.resolveTypeInPool(Native Method)
+	at jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVM.resolveTypeInPool(CompilerToVM.java:563)
+	at jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotConstantPool.loadReferencedType(HotSpotConstantPool.java:893)
+	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.infrastructure.WrappedConstantPool.loadReferencedType(WrappedConstantPool.java:90)
+	... 55 more

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Dec 16, 2024
@graalvmbot graalvmbot closed this Dec 16, 2024
@graalvmbot graalvmbot deleted the ds/GR-60554 branch December 16, 2024 22:54
@graalvmbot graalvmbot merged commit 1cdb5aa into master Dec 16, 2024
13 checks passed
@zakkak
Copy link
Collaborator

zakkak commented Dec 17, 2024

Hi @dougxc do I get it right that this PR aim is to resolve #6253?

Could you please mirror the internal description as well?

@dougxc
Copy link
Member

dougxc commented Dec 17, 2024

Hi @dougxc do I get it right that this PR aim is to resolve #6253?

It certainly goes a long way in helping. There's also https://bugs.openjdk.org/browse/JDK-8346282 which might allow Native Image to further improve transparency of linkage errors. @cstancu may be able to comment better on that.

In terms of this comment:

we would need to preserve resolution and linking errors via JVMCI, where they are currently just ignored.

The one instance of this I'm aware of is being fixed. If there are other cases, please let me know.

@zakkak
Copy link
Collaborator

zakkak commented Dec 17, 2024

Thank you @dougxc.

The one instance of this I'm aware of is being fixed. If there are other cases, please let me know.

Sure

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

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement. redhat-interest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants