Closed davecramer closed 1 year ago
Thanks for the bug report, @davecramer. This appears to be a problem in AOT-compiled FastR. I can reproduce the issue on my machine and the reason for the NPE is the below. Assigning this to our FastR team...
Caused by: java.lang.NullPointerException
at sun.nio.fs.UnixPath.normalizeAndCheck(UnixPath.java:75)
at sun.nio.fs.UnixPath.<init>(UnixPath.java:69)
at sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:279)
at java.nio.file.Path.of(Path.java:147)
at java.nio.file.Paths.get(Paths.java:69)
at com.oracle.truffle.polyglot.FileSystems$NIOFileSystem.parsePath(FileSystems.java:759)
at com.oracle.truffle.polyglot.FileSystems$PreInitializeContextFileSystem.parsePath(FileSystems.java:307)
at com.oracle.truffle.api.TruffleLanguage$Env.getInternalTruffleFile(TruffleLanguage.java:2596)
at com.oracle.truffle.llvm.runtime.ToolchainImpl.getSysroot(ToolchainImpl.java:149)
at com.oracle.truffle.llvm.runtime.ToolchainImpl.getWrappersRoot(ToolchainImpl.java:140)
at com.oracle.truffle.llvm.runtime.ToolchainImpl.getToolPathImpl(ToolchainImpl.java:86)
at com.oracle.truffle.llvm.runtime.ToolchainImpl.getToolPath(ToolchainImpl.java:54)
at com.oracle.truffle.r.nodes.builtin.base.system.ProcessSystemFunctionFactory.putToolChainVars(ProcessSystemFunctionFactory.java:166)
at com.oracle.truffle.r.nodes.builtin.base.system.ProcessSystemFunctionFactory.updateEnvironment(ProcessSystemFunctionFactory.java:143)
at com.oracle.truffle.r.nodes.builtin.base.system.ProcessSystemFunctionFactory.execute(ProcessSystemFunctionFactory.java:74)
at com.oracle.truffle.r.nodes.builtin.base.system.ProcessSystemFunctionFactory.execute(ProcessSystemFunctionFactory.java:64)
at com.oracle.truffle.r.nodes.builtin.base.system.SystemFunction.system(SystemFunction.java:57)
at com.oracle.truffle.r.nodes.builtin.base.system.SystemFunctionNodeGen.executeAndSpecialize(SystemFunctionNodeGen.java:64)
at com.oracle.truffle.r.nodes.builtin.base.system.SystemFunctionNodeGen.execute(SystemFunctionNodeGen.java:43)
at com.oracle.truffle.r.nodes.builtin.RBuiltinNode$Arg3.call(RBuiltinNode.java:214)
at com.oracle.truffle.r.nodes.builtin.InternalNode$InternalCallNode.execute(InternalNode.java:260)
at com.oracle.truffle.r.nodes.builtin.InternalNode$InternalUninitializedNode.execute(InternalNode.java:201)
at com.oracle.truffle.r.runtime.nodes.RNode.visibleExecute(RNode.java:86)
at com.oracle.truffle.r.nodes.control.RBlockNode.executeGeneric(RBlockNode.java:87)
at com.oracle.truffle.r.nodes.control.RBlockNode.executeGeneric(RBlockNode.java:35)
at org.graalvm.compiler.truffle.runtime.OptimizedBlockNode.executeGeneric(OptimizedBlockNode.java:81)
at com.oracle.truffle.r.nodes.control.RBlockNode.visibleExecute(RBlockNode.java:62)
at com.oracle.truffle.r.nodes.function.FunctionBodyNode.visibleExecute(FunctionBodyNode.java:67)
at com.oracle.truffle.r.nodes.function.FunctionDefinitionNode.execute(FunctionDefinitionNode.java:292)
... 723 more
@fniephaus thanks!
Given this part of the stack trace:
at com.oracle.truffle.api.TruffleLanguage$Env.getInternalTruffleFile(TruffleLanguage.java:2596)
at com.oracle.truffle.llvm.runtime.ToolchainImpl.getSysroot(ToolchainImpl.java:149)
at com.oracle.truffle.llvm.runtime.ToolchainImpl.getWrappersRoot(ToolchainImpl.java:140)
at com.oracle.truffle.llvm.runtime.ToolchainImpl.getToolPathImpl(ToolchainImpl.java:86)
at com.oracle.truffle.llvm.runtime.ToolchainImpl.getToolPath(ToolchainImpl.java:54)
it almost seems like Sulong perhaps cannot handle it when the language home is not set, which is the most suspicious difference between JVM/native execution that comes to my mind. /CC @rschatz
That would seem to make sense. R_HOME does tend to cause quite a few problems. The error message is less than helpful though
I just checked and R_HOME is set correctly. If it is not set correctly the output is different
./build/native/nativeCompile/testgraal
Hello Java!
Exception in thread "main" Cannot determine the R home. Please export environment variable R_HOME with path to the FastR home directory. FastR home is usually located in {GraalVM}/jre/languages/R in JDK8 based builds and in {GraalVM}/languages/R in JDK11 based builds.
at org.graalvm.polyglot.Context.eval(Context.java:425)
at org.postgresql.Test.main(Test.java:12)
This might be a problem of not finding the LLVM language home. Can you try with this instead?
testgraal -Dorg.graalvm.language.llvm.home=<path-to-graalvm>/languages/llvm
If that works, you can also try -Dorg.graalvm.launcher.relative.llvm.home=...
at image build time, to hardcode a relative path from the native-image to the LLVM home into the image. Then you don't need the argument at runtime anymore as long as the LLVM home can be found at the specified relative path.
I agree that the exception is not helpful at all, we should probably improve that, and give a sensible error message.
./build/native/nativeCompile/testgraal -D org.graalvm.language.llvm.home=$GRAALVM_HOME/languages/llvm
Hello Java!
FastR internal error: java.lang.NullPointerException
An internal error occurred: "java.lang.NullPointerException"
Please report an issue at https://github.com/oracle/fastr including the commands and the error log file '/Users/davecra/projects/testgraal/fastr_errors.log'.
[1] "Hello R!"
Same error. It is interesting to note that the R program does run
You have an extra space between the -D
and the rest ;)
ha! of course I did, and that worked!
./build/native/nativeCompile/testgraal -Dorg.graalvm.language.llvm.home=$GRAALVM_HOME/languages/llvm
Hello Java!
[1] "Hello R!"
Thanks!
Problem seems fixed, closing
com.oracle.truffle.r.runtime.RInternalError: java.lang.NullPointerException at com.oracle.truffle.r.nodes.function.FunctionDefinitionNode.execute(FunctionDefinitionNode.java:342) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:655) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:627) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:560) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.invokeCallBoundary(SubstrateOptimizedCallTarget.java:121) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTargetInstalledCode.doInvoke(SubstrateOptimizedCallTargetInstalledCode.java:176) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.doInvoke(SubstrateOptimizedCallTarget.java:104) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:486) at org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode.call(OptimizedDirectCallNode.java:71) at com.oracle.truffle.r.nodes.function.call.CallRFunctionNode.execute(CallRFunctionNode.java:63) at com.oracle.truffle.r.nodes.function.RCallNode$DispatchedCallNode.execute(RCallNode.java:1233) at com.oracle.truffle.r.nodes.function.RCallNode$FunctionDispatch.dispatch(RCallNode.java:920) at com.oracle.truffle.r.nodes.function.RCallNodeGen$FunctionDispatchNodeGen.executeAndSpecialize(RCallNodeGen.java:742) at com.oracle.truffle.r.nodes.function.RCallNodeGen$FunctionDispatchNodeGen.execute(RCallNodeGen.java:705) at com.oracle.truffle.r.nodes.function.RCallNode.call(RCallNode.java:295) at com.oracle.truffle.r.nodes.function.RCallNodeGen.executeAndSpecialize(RCallNodeGen.java:233) at com.oracle.truffle.r.nodes.function.RCallNodeGen.execute(RCallNodeGen.java:208) at com.oracle.truffle.r.runtime.nodes.RNode.visibleExecute(RNode.java:86) at com.oracle.truffle.r.nodes.function.WrapArgumentBaseNode.visibleExecute(WrapArgumentBaseNode.java:63) at com.oracle.truffle.r.nodes.InlineCacheNode.doCached(InlineCacheNode.java:71) at com.oracle.truffle.r.nodes.InlineCacheNodeGen.executeAndSpecialize(InlineCacheNodeGen.java:84) at com.oracle.truffle.r.nodes.InlineCacheNodeGen.execute(InlineCacheNodeGen.java:46) at com.oracle.truffle.r.nodes.function.PromiseHelperNode.generateValueFromFullPromise(PromiseHelperNode.java:230) at com.oracle.truffle.r.nodes.function.PromiseHelperNode.evaluateImpl(PromiseHelperNode.java:210) at com.oracle.truffle.r.nodes.function.PromiseHelperNode.visibleEvaluate(PromiseHelperNode.java:184) at com.oracle.truffle.r.nodes.function.PromiseHelperNode$GenerateValueForEagerPromiseNode.evaluateNextNode(PromiseHelperNode.java:571) at com.oracle.truffle.r.nodes.function.PromiseHelperNode$GenerateValueForEagerPromiseNode.generateValue(PromiseHelperNode.java:587) at com.oracle.truffle.r.nodes.function.PromiseHelperNode$GenerateValueForEagerPromiseNode.doCachedAssumption(PromiseHelperNode.java:535) at com.oracle.truffle.r.nodes.function.PromiseHelperNodeFactory$GenerateValueForEagerPromiseNodeGen.executeAndSpecialize(PromiseHelperNodeFactory.java:119) at com.oracle.truffle.r.nodes.function.PromiseHelperNodeFactory$GenerateValueForEagerPromiseNodeGen.execute(PromiseHelperNodeFactory.java:68) at com.oracle.truffle.r.nodes.function.PromiseHelperNode.generateValueFromEagerPromise(PromiseHelperNode.java:284) at com.oracle.truffle.r.nodes.function.PromiseHelperNode.evaluateImpl(PromiseHelperNode.java:212) at com.oracle.truffle.r.nodes.function.PromiseHelperNode.visibleEvaluate(PromiseHelperNode.java:184) at com.oracle.truffle.r.nodes.access.variables.ReadVariableNode.executeInternal(ReadVariableNode.java:297) at com.oracle.truffle.r.nodes.access.variables.LookupNode.visibleExecute(ReadVariableNode.java:117) at com.oracle.truffle.r.nodes.control.RBlockNode.executeGeneric(RBlockNode.java:87) at com.oracle.truffle.r.nodes.control.RBlockNode.executeGeneric(RBlockNode.java:35) at org.graalvm.compiler.truffle.runtime.OptimizedBlockNode.executeGeneric(OptimizedBlockNode.java:81) at com.oracle.truffle.r.nodes.control.RBlockNode.visibleExecute(RBlockNode.java:62) at com.oracle.truffle.r.nodes.function.FunctionBodyNode.visibleExecute(FunctionBodyNode.java:67) at com.oracle.truffle.r.nodes.function.FunctionDefinitionNode.execute(FunctionDefinitionNode.java:292) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:655) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:627) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:560) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.invokeCallBoundary(SubstrateOptimizedCallTarget.java:121) at