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

NPE when accessing FileFormatSPI #11088

Open
hubertp opened this issue Sep 16, 2024 · 3 comments
Open

NPE when accessing FileFormatSPI #11088

hubertp opened this issue Sep 16, 2024 · 3 comments
Assignees
Labels
-libs Libraries: New libraries to be implemented p-high Should be completed in the next sprint

Comments

@hubertp
Copy link
Contributor

hubertp commented Sep 16, 2024

[WARN] [2024-09-16T13:09:44.334] [enso.org.enso.interpreter.service.ExecutionService] Execution of function main failed (Cannot invoke "Object.getClass()" because "arg2Value" is null).
java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "arg2Value" is null
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotLanguageContextFactory$ToHostValueNodeGen$Inlined.execute(PolyglotLanguageContextFactory.java:84)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatch$InteropValue$SharedInvokeNode.doDefault(PolyglotValueDispatch.java:4781)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatchFactory$InteropValueFactory$SharedInvokeNodeGen$Inlined.executeShared(PolyglotValueDispatchFactory.java:10501)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatch$InteropValue$InvokeNode.doDefault(PolyglotValueDispatch.java:4821)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatchFactory$InteropValueFactory$InvokeNodeGen.executeImpl(PolyglotValueDispatchFactory.java:10729)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.HostToGuestRootNode.execute(HostToGuestRootNode.java:124)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:745)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:669)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:602)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.doInvoke(OptimizedCallTarget.java:586)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedRuntimeSupport.callProfiled(OptimizedRuntimeSupport.java:266)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatch$InteropValue.invoke(PolyglotValueDispatch.java:2662)
        at org.graalvm.polyglot/org.graalvm.polyglot.Value.invokeMember(Value.java:1023)
        at org.enso.base.polyglot.EnsoMeta.getType(EnsoMeta.java:15)
        at org.enso.base.file_format.FileFormatSPI.getTypeObject(FileFormatSPI.java:48)
        at org.enso.base.file_format.FileFormatSPI.lambda$get_types$0(FileFormatSPI.java:17)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.ServiceLoader$ProviderSpliterator.tryAdvance(ServiceLoader.java:1499)
        at java.base/java.util.Spliterator.forEachRemaining(Spliterator.java:332)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)
        at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
        at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
        at org.enso.base.file_format.FileFormatSPI.get_types(FileFormatSPI.java:17)
        at org.graalvm.truffle/com.oracle.truffle.host.HostMethodDesc$SingleMethod$MHBase.invokeHandle(HostMethodDesc.java:371)
        at org.graalvm.truffle/com.oracle.truffle.host.GuestToHostCodeCache$GuestToHostInvokeHandle.executeImpl(GuestToHostCodeCache.java:88)
        at org.graalvm.truffle/com.oracle.truffle.host.GuestToHostRootNode.execute(GuestToHostRootNode.java:80)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:745)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.callInlined(OptimizedCallTarget.java:550)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedRuntimeSupport.callInlined(OptimizedRuntimeSupport.java:250)
        at org.graalvm.truffle/com.oracle.truffle.host.GuestToHostRootNode.guestToHostCall(GuestToHostRootNode.java:102)
        at org.graalvm.truffle/com.oracle.truffle.host.HostMethodDesc$SingleMethod$MHBase.invokeGuestToHost(HostMethodDesc.java:407)
        at org.graalvm.truffle/com.oracle.truffle.host.HostExecuteNode.doInvoke(HostExecuteNode.java:877)
        at org.graalvm.truffle/com.oracle.truffle.host.HostExecuteNode.doFixed(HostExecuteNode.java:140)
        at org.graalvm.truffle/com.oracle.truffle.host.HostExecuteNodeGen$Inlined.executeAndSpecialize(HostExecuteNodeGen.java:403)
        at org.graalvm.truffle/com.oracle.truffle.host.HostExecuteNodeGen$Inlined.execute(HostExecuteNodeGen.java:363)
        at org.graalvm.truffle/com.oracle.truffle.host.HostObject.invokeMember(HostObject.java:465)
        at org.graalvm.truffle/com.oracle.truffle.host.HostObjectGen$InteropLibraryExports$Cached.invokeMemberNode_AndSpecialize(HostObjectGen.java:7156)
        at org.graalvm.truffle/com.oracle.truffle.host.HostObjectGen$InteropLibraryExports$Cached.invokeMember(HostObjectGen.java:7142)
        at org.graalvm.truffle/com.oracle.truffle.api.interop.InteropLibraryGen$CachedDispatch.invokeMember(InteropLibraryGen.java:8549)
        at org.enso.runtime/org.enso.interpreter.node.callable.resolver.HostMethodCallNode.resolveHostMethod(HostMethodCallNode.java:223)
        at org.enso.runtime/org.enso.interpreter.node.callable.resolver.HostMethodCallNodeGen.executeAndSpecialize(HostMethodCallNodeGen.java:157)
        at org.enso.runtime/org.enso.interpreter.node.callable.resolver.HostMethodCallNodeGen.execute(HostMethodCallNodeGen.java:119)
        at org.enso.runtime/org.enso.interpreter.node.callable.InvokeMethodNode.doPolyglot(InvokeMethodNode.java:542)
        at org.enso.runtime/org.enso.interpreter.node.callable.InvokeMethodNodeGen.executeAndSpecialize(InvokeMethodNodeGen.java:878)
        at org.enso.runtime/org.enso.interpreter.node.callable.InvokeMethodNodeGen.execute(InvokeMethodNodeGen.java:535)
        at org.enso.runtime/org.enso.interpreter.node.callable.InvokeCallableNode.invokeDynamicSymbol(InvokeCallableNode.java:276)
        at org.enso.runtime/org.enso.interpreter.node.callable.InvokeCallableNodeGen.executeAndSpecialize(InvokeCallableNodeGen.java:280)
        at org.enso.runtime/org.enso.interpreter.node.callable.InvokeCallableNodeGen.execute(InvokeCallableNodeGen.java:232)
        at org.enso.runtime/org.enso.interpreter.node.callable.ApplicationNode.executeGeneric(ApplicationNode.java:97)
        at org.enso.runtime/org.enso.interpreter.node.ClosureRootNode.execute(ClosureRootNode.java:85)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:745)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:669)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:602)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.doInvoke(OptimizedCallTarget.java:586)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:535)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedDirectCallNode.call(OptimizedDirectCallNode.java:94)
        at org.enso.runtime/org.enso.interpreter.node.callable.thunk.ThunkExecutorNode.doCached(ThunkExecutorNode.java:69)
        at org.enso.runtime/org.enso.interpreter.node.callable.thunk.ThunkExecutorNodeGen.executeAndSpecialize(ThunkExecutorNodeGen.java:208)
        at org.enso.runtime/org.enso.interpreter.node.callable.thunk.ThunkExecutorNodeGen.executeThunk(ThunkExecutorNodeGen.java:168)
        at org.enso.runtime/org.enso.interpreter.node.callable.argument.ArgumentSorterNode.executeArguments(ArgumentSorterNode.java:84)
        at org.enso.runtime/org.enso.interpreter.node.callable.argument.ArgumentSorterNode.execute(ArgumentSorterNode.java:100)
        at org.enso.runtime/org.enso.interpreter.node.callable.dispatch.InvokeFunctionNode.invokeCached(InvokeFunctionNode.java:146)
        at org.enso.runtime/org.enso.interpreter.node.callable.dispatch.InvokeFunctionNodeGen.executeAndSpecialize(InvokeFunctionNodeGen.java:137)
        at org.enso.runtime/org.enso.interpreter.node.callable.dispatch.InvokeFunctionNodeGen.execute(InvokeFunctionNodeGen.java:99)
        at org.enso.runtime/org.enso.interpreter.node.callable.InvokeMethodNode.doFunctionalDispatchCachedSymbol(InvokeMethodNode.java:162)
        at org.enso.runtime/org.enso.interpreter.node.callable.InvokeMethodNodeGen.executeAndSpecialize(InvokeMethodNodeGen.java:614)
        at org.enso.runtime/org.enso.interpreter.node.callable.InvokeMethodNodeGen.execute(InvokeMethodNodeGen.java:535)
        at org.enso.runtime/org.enso.interpreter.node.callable.InvokeCallableNode.invokeDynamicSymbol(InvokeCallableNode.java:276)
        at org.enso.runtime/org.enso.interpreter.node.callable.InvokeCallableNodeGen.executeAndSpecialize(InvokeCallableNodeGen.java:280)
        at org.enso.runtime/org.enso.interpreter.node.callable.InvokeCallableNodeGen.execute(InvokeCallableNodeGen.java:232)
        at org.enso.runtime/org.enso.interpreter.node.callable.ApplicationNode.executeGeneric(ApplicationNode.java:97)
        at org.enso.runtime/org.enso.interpreter.node.callable.function.BlockNode.executeGeneric(BlockNode.java:61)
        at org.enso.runtime/org.enso.interpreter.node.callable.function.BlockNode.executeGeneric(BlockNode.java:61)
        at org.enso.runtime/org.enso.interpreter.node.ClosureRootNode.execute(ClosureRootNode.java:85)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:745)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:669)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:602)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.doInvoke(OptimizedCallTarget.java:586)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:535)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedDirectCallNode.call(OptimizedDirectCallNode.java:94)
        at org.enso.runtime/org.enso.interpreter.node.callable.ExecuteCallNode.callDirect(ExecuteCallNode.java:94)
        at org.enso.runtime/org.enso.interpreter.node.callable.ExecuteCallNodeGen.executeAndSpecialize(ExecuteCallNodeGen.java:171)... (17 KB left)

and another exception reported as #11104

@hubertp hubertp added p-high Should be completed in the next sprint -compiler labels Sep 16, 2024
@hubertp hubertp self-assigned this Sep 16, 2024
@hubertp hubertp assigned JaroslavTulach and unassigned hubertp Sep 16, 2024
@hubertp
Copy link
Contributor Author

hubertp commented Sep 16, 2024

[WARN] [2024-09-16T14:45:35.283] [enso.org.enso.interpreter.service.ExecutionService] Execution of function main failed (Cannot invoke "Object.getClass()" because "arg2Value" is null).
java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "arg2Value" is null
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotLanguageContextFactory$ToHostValueNodeGen$Inlined.execute(PolyglotLanguageContextFactory.java:84)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatch$InteropValue$SharedInvokeNode.doDefault(PolyglotValueDispatch.java:4781)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatchFactory$InteropValueFactory$SharedInvokeNodeGen$Inlined.executeShared(PolyglotValueDispatchFactory.java:10501)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatch$InteropValue$InvokeNode.doDefault(PolyglotValueDispatch.java:4821)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatchFactory$InteropValueFactory$InvokeNodeGen.executeImpl(PolyglotValueDispatchFactory.java:10729)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.HostToGuestRootNode.execute(HostToGuestRootNode.java:124)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:745)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:669)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:602)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.doInvoke(OptimizedCallTarget.java:586)
        at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedRuntimeSupport.callProfiled(OptimizedRuntimeSupport.java:266)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatch$InteropValue.invoke(PolyglotValueDispatch.java:2662)
        at org.graalvm.polyglot/org.graalvm.polyglot.Value.invokeMember(Value.java:1023)
        at org.enso.base.polyglot.EnsoMeta.getType(EnsoMeta.java:15)
        at org.enso.base.file_format.FileFormatSPI.getTypeObject(FileFormatSPI.java:48)
        at org.enso.base.file_format.FileFormatSPI.lambda$get_types$0(FileFormatSPI.java:17)
...
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ff8f8b60cfa, pid=16364, tid=38040
#
# JRE version: OpenJDK Runtime Environment GraalVM CE 21.0.2+13.1 (21.0.2+13) (build 21.0.2+13-jvmci-23.1-b30)
# Java VM: OpenJDK 64-Bit Server VM GraalVM CE 21.0.2+13.1 (21.0.2+13-jvmci-23.1-b30, mixed mode, sharing, tiered, jvmci, jvmci compiler, compressed oops, compressed class ptrs, g1 gc, windows-amd64)
# Problematic frame:
# C  [enso_parser.dll+0x30cfa]
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# If you would like to submit a bug report, please visit:
#   https://github.com/oracle/graal/issues
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

and core dump:
hs_err_pid16364.log

@hubertp hubertp mentioned this issue Sep 17, 2024
@JaroslavTulach JaroslavTulach added -libs Libraries: New libraries to be implemented and removed -compiler -parser labels Sep 17, 2024
@JaroslavTulach
Copy link
Member

Please note the last line in this exception is at org.enso.base.polyglot.EnsoMeta.getType - e.g. it is a library code. There is no sign of any Enso engine code running. I suggest to patch with:

$ git diff std-bits/base/src/main/java/org/enso/base/polyglot/EnsoMeta.java
diff --git std-bits/base/src/main/java/org/enso/base/polyglot/EnsoMeta.java std-bits/base/src/main/java/org/enso/base/polyglot/EnsoMeta.java
index 249dcd2ad5..b56ff57aef 100644
--- std-bits/base/src/main/java/org/enso/base/polyglot/EnsoMeta.java
+++ std-bits/base/src/main/java/org/enso/base/polyglot/EnsoMeta.java
@@ -12,7 +12,13 @@ public final class EnsoMeta {
   /** Returns a type object from the Enso runtime. */
   public static Value getType(String moduleName, String typeName) {
     var module = getBindings().invokeMember("get_module", moduleName);
-    return module.invokeMember("get_type", typeName);
+    try {
+      return module.invokeMember("get_type", typeName);
+    } catch (NullPointerException e) {
+      var ex = new NullPointerException("Cannot get type for " + moduleName + " type: " + typeName + " at " + module);
+      ex.initCause(ex);
+      throw ex;
+    }
   }
 
   /** Calls a static method defined directly on a module (not inside of a type). */

and wait until it reproduces.

hubertp added a commit that referenced this issue Sep 18, 2024
We are seeing this problem almost daily and need more info rather
urgently.
Related to #11088.
hubertp added a commit that referenced this issue Sep 18, 2024
We are seeing this problem almost daily and need more info rather
urgently.
Related to #11088.
@JaroslavTulach
Copy link
Member

JaroslavTulach commented Sep 19, 2024

$ git diff std-bits/base/src/main/java/org/enso/base/polyglot/EnsoMeta.java
diff --git std-bits/base/src/main/java/org/enso/base/polyglot/EnsoMeta.java std-bits/base/src/main/java/org/enso/base/polyglot/EnsoMeta.java
index 249dcd2ad5..b56ff57aef 100644
--- std-bits/base/src/main/java/org/enso/base/polyglot/EnsoMeta.java
+++ std-bits/base/src/main/java/org/enso/base/polyglot/EnsoMeta.java
@@ -12,7 +12,13 @@ public final class EnsoMeta {
   /** Returns a type object from the Enso runtime. */
   public static Value getType(String moduleName, String typeName) {
     var module = getBindings().invokeMember("get_module", moduleName);
-    return module.invokeMember("get_type", typeName);
+    try {
+      return module.invokeMember("get_type", typeName);
+    } catch (NullPointerException npe) {
+      var ex = new NullPointerException("Cannot get type for " + moduleName + " type: " + typeName + " at " + module);
+      ex.initCause(npe);
+      throw ex;
+    }
   }
 
   /** Calls a static method defined directly on a module (not inside of a type). */

The enhanced logging diff has been integrated by #11125. Now we need a new bug report with the additional info.

kazcw added a commit that referenced this issue Sep 19, 2024
- Fix debug logging for #11088--attempt to create an exception that is its own
  cause fails.
- In case the parser is used after closing, throw an `IllegalStateException`
  instead of UB.
mergify bot pushed a commit that referenced this issue Sep 20, 2024
- Fix debug logging for #11088 case--attempt to create an exception that is its own cause fails.
- In case the parser is used after closing, throw an `IllegalStateException` instead of UB. (This case is not known to occur and doesn't seem to be behind the #11121, but we should handle it more safely if it does.)
jdunkerley pushed a commit that referenced this issue Sep 26, 2024
We are seeing this problem almost daily and need more info rather
urgently.
Related to #11088.

(cherry picked from commit 2c362ea)
jdunkerley pushed a commit that referenced this issue Sep 26, 2024
- Fix debug logging for #11088 case--attempt to create an exception that is its own cause fails.
- In case the parser is used after closing, throw an `IllegalStateException` instead of UB. (This case is not known to occur and doesn't seem to be behind the #11121, but we should handle it more safely if it does.)

(cherry picked from commit e587d56)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-libs Libraries: New libraries to be implemented p-high Should be completed in the next sprint
Projects
Status: New
Development

No branches or pull requests

3 participants