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

UnsupportedSpecializationException in polyglot evaluation of the R mean function #202

Open
Akirathan opened this issue Jul 13, 2022 · 2 comments
Labels

Comments

@Akirathan
Copy link
Contributor

Reproducer

Download GraalVM release (tried on java11-22.1.0 version), install js and R components, create polyglot.js and evaluate it:

polyglot.js:

const mean = Polyglot.eval("R", "mean")
const result = mean([1,2,3])
$GRAALVM_HOME/bin/js --polyglot polyglot.js

Stacktrace:

org.graalvm.polyglot.PolyglotException: com.oracle.truffle.r.runtime.RInternalError: com.oracle.truffle.api.dsl.UnsupportedSpecializationException: Unexpected values provided for mean: [DynamicObject<JSArray>@28c50fcb], [JSArrayObject]
        at com.oracle.truffle.r.nodes.function.FunctionDefinitionNode.execute(FunctionDefinitionNode.java:342)
        at  <R> mean.default(Unknown)
        at  <R> mean(unknown.r:1:0-16)
        at <js> :program(internal:1:0)
        at org.graalvm.sdk/org.graalvm.polyglot.Context.eval(Context.java:399)
        at com.oracle.truffle.js.shell.JSLauncher.executeScripts(JSLauncher.java:348)
        at com.oracle.truffle.js.shell.JSLauncher.launch(JSLauncher.java:88)
        at org.graalvm.launcher.AbstractLanguageLauncher.launch(AbstractLanguageLauncher.java:296)
        at org.graalvm.launcher.PolyglotLauncher.switchToLauncher(PolyglotLauncher.java:349)
        at org.graalvm.launcher.PolyglotLauncher.launchImpl(PolyglotLauncher.java:206)
        at org.graalvm.launcher.PolyglotLauncher.launch(PolyglotLauncher.java:186)
        at org.graalvm.launcher.PolyglotLauncher.main(PolyglotLauncher.java:438)
Original Internal Error:
com.oracle.truffle.r.runtime.RInternalError: com.oracle.truffle.api.dsl.UnsupportedSpecializationException: Unexpected values provided for mean: [DynamicObject<JSArray>@28c50fcb], [JSArrayObject]
        at com.oracle.truffle.r.nodes.function.FunctionDefinitionNode.execute(FunctionDefinitionNode.java:342)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:659)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:631)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:564)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.doInvoke(OptimizedCallTarget.java:548)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:490)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode.call(OptimizedDirectCallNode.java:68)
        at com.oracle.truffle.r.nodes.function.call.CallRFunctionNode.execute(CallRFunctionNode.java:63)
        at com.oracle.truffle.r.nodes.function.CallMatcherNode$CallMatcherCachedNode.execute(CallMatcherNode.java:294)
        at com.oracle.truffle.r.nodes.function.CallMatcherNode$CallMatcherUninitializedNode.execute(CallMatcherNode.java:195)
        at com.oracle.truffle.r.nodes.builtin.base.S3DispatchFunctions$Helper.dispatch(S3DispatchFunctions.java:114)        at com.oracle.truffle.r.nodes.builtin.base.S3DispatchFunctions$UseMethod.execute(S3DispatchFunctions.java:196)
        at com.oracle.truffle.r.nodes.builtin.base.S3DispatchFunctionsFactory$UseMethodNodeGen.executeAndSpecialize(S3DispatchFunctionsFactory.java:42)
        at com.oracle.truffle.r.nodes.builtin.base.S3DispatchFunctionsFactory$UseMethodNodeGen.execute(S3DispatchFunctionsFactory.java:34)
        at com.oracle.truffle.r.nodes.builtin.RBuiltinNode$Arg2.call(RBuiltinNode.java:201)
        at com.oracle.truffle.r.nodes.function.RCallNode$BuiltinCallNode.execute(RCallNode.java:1164)
        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:87)
        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 jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:659)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:631)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:564)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.doInvoke(OptimizedCallTarget.java:548)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:490)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode.call(OptimizedDirectCallNode.java:68)
        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:151)
        at com.oracle.truffle.r.nodes.function.call.RExplicitCallNode.doCall(RExplicitCallNode.java:70)
        at com.oracle.truffle.r.nodes.function.call.RExplicitCallNodeGen.executeAndSpecialize(RExplicitCallNodeGen.java:44)
        at com.oracle.truffle.r.nodes.function.call.RExplicitCallNodeGen.execute(RExplicitCallNodeGen.java:31)
        at com.oracle.truffle.r.nodes.function.call.RExplicitCallNode.call(RExplicitCallNode.java:54)
        at com.oracle.truffle.r.runtime.data.RFunction$CachedExplicitCall.call(RFunction.java:197)
        at com.oracle.truffle.r.runtime.data.RFunctionFactory$CachedExplicitCallNodeGen.executeAndSpecialize(RFunctionFactory.java:60)
        at com.oracle.truffle.r.runtime.data.RFunctionFactory$CachedExplicitCallNodeGen.execute(RFunctionFactory.java:38)
        at com.oracle.truffle.r.runtime.data.RFunction.execute(RFunction.java:97)
        at com.oracle.truffle.r.runtime.data.RFunctionGen$InteropLibraryExports$Cached.executeAndSpecialize(RFunctionGen.java:93)
        at com.oracle.truffle.r.runtime.data.RFunctionGen$InteropLibraryExports$Cached.execute(RFunctionGen.java:76)
        at org.graalvm.truffle/com.oracle.truffle.api.interop.InteropLibraryGen$CachedDispatch.execute(InteropLibraryGen.java:7648)
        at com.oracle.truffle.js.nodes.function.JSFunctionCallNode$ForeignExecuteNode.executeCall(JSFunctionCallNode.java:1459)
        at com.oracle.truffle.js.nodes.function.JSFunctionCallNode.executeAndSpecialize(JSFunctionCallNode.java:305)
        at com.oracle.truffle.js.nodes.function.JSFunctionCallNode.executeCall(JSFunctionCallNode.java:250)
        at com.oracle.truffle.js.nodes.function.JSFunctionCallNode$CallNode.execute(JSFunctionCallNode.java:531)
        at com.oracle.truffle.js.nodes.access.WritePropertyNode.executeAndSpecialize(WritePropertyNode.java:284)
        at com.oracle.truffle.js.nodes.access.WritePropertyNode.executeVoid(WritePropertyNode.java:256)
        at com.oracle.truffle.js.nodes.control.AbstractBlockNode.executeVoid(AbstractBlockNode.java:80)
        at com.oracle.truffle.js.nodes.control.AbstractBlockNode.executeVoid(AbstractBlockNode.java:55)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedBlockNode.executeGeneric(OptimizedBlockNode.java:78)
        at com.oracle.truffle.js.nodes.control.AbstractBlockNode.execute(AbstractBlockNode.java:75)
        at com.oracle.truffle.js.nodes.binary.DualNode.execute(DualNode.java:125)
        at com.oracle.truffle.js.nodes.function.FunctionBodyNode.execute(FunctionBodyNode.java:73)
        at com.oracle.truffle.js.nodes.function.FunctionRootNode.executeInRealm(FunctionRootNode.java:149)
        at com.oracle.truffle.js.runtime.JavaScriptRealmBoundaryRootNode.execute(JavaScriptRealmBoundaryRootNode.java:92)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:659)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:631)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:564)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.doInvoke(OptimizedCallTarget.java:548)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:490)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode.call(OptimizedDirec
tCallNode.java:68)
        at com.oracle.truffle.js.lang.JavaScriptLanguage$ParsedProgramRoot.execute(JavaScriptLanguage.java:245)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:659)

        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:631)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:564)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.doInvoke(OptimizedCallTarget.java:548)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callIndirect(OptimizedCallTarget.java:472)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.call(OptimizedCallTarget.java:453)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotContextImpl.eval(PolyglotContextImpl.java:1326)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotContextDispatch.eval(PolyglotContextDispatch.java:63)
        at org.graalvm.sdk/org.graalvm.polyglot.Context.eval(Context.java:399)
        at com.oracle.truffle.js.shell.JSLauncher.executeScripts(JSLauncher.java:348)
        at com.oracle.truffle.js.shell.JSLauncher.launch(JSLauncher.java:88)
        at org.graalvm.launcher.AbstractLanguageLauncher.launch(AbstractLanguageLauncher.java:296)
        at org.graalvm.launcher.PolyglotLauncher.switchToLauncher(PolyglotLauncher.java:349)
        at org.graalvm.launcher.PolyglotLauncher.launchImpl(PolyglotLauncher.java:206)
        at org.graalvm.launcher.PolyglotLauncher.launch(PolyglotLauncher.java:186)
        at org.graalvm.launcher.PolyglotLauncher.main(PolyglotLauncher.java:438)
Caused by: com.oracle.truffle.api.dsl.UnsupportedSpecializationException: Unexpected values provided for mean: [DynamicObject<JSArray>@28c50fcb], [JSArrayObject]
        at com.oracle.truffle.r.nodes.builtin.base.MeanNodeGen.executeAndSpecialize(MeanNodeGen.java:181)
        at com.oracle.truffle.r.nodes.builtin.base.MeanNodeGen.execute(MeanNodeGen.java:71)
        at com.oracle.truffle.r.nodes.builtin.RBuiltinNode$Arg1.call(RBuiltinNode.java:188)
        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:87)
        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 jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedBlockNode.executeGeneric(OptimizedBlockNode.java:80)
        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)
        ... 86 more
Caused by: Attached Guest Language Frames (4)
@Akirathan Akirathan added the bug label Jul 13, 2022
@Akirathan
Copy link
Contributor Author

Should be straightforward to fix - just provide a specialization for foreign types in com.oracle.truffle.r.nodes.builtin.base.Mean node.

@steve-s
Copy link
Member

steve-s commented Jul 13, 2022

Alternatively the cast pipeline should convert foreign values to R vector wrappers, so that specializations in com.oracle.truffle.r.nodes.builtin.base.Mean can stay as is. Maybe Mean is not using cast pipeline or it is not configured to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants