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

TruffleRuby doesn't have a case for the com.oracle.truffle.llvm.runtime.nodes.cast.LLVMToAddressNodeGen node with values of type com.oracle.truffle.nfi.NFISymbol #2634

Closed
nvh0412 opened this issue Mar 22, 2022 · 8 comments

Comments

@nvh0412
Copy link

nvh0412 commented Mar 22, 2022

TruffleRuby raised the error when I was trying to run a gRPC server with our truffle ruby (patched to run grpc via)

Error

/home/nvh0412/.rbenv/versions/truffleruby-21.3.0/lib/truffle/truffle/cext.rb:1239:in `__allocate__': TruffleRuby doesn't have a case for the com.oracle.truffle.llvm.runtime.nodes.cast.LLVMToAddressNodeGen node with values of type com.oracle.truffle.nfi.NFISymbol (TypeError)
        from com.oracle.truffle.llvm.runtime.nodes.cast.LLVMToAddressNodeGen.executeAndSpecialize(LLVMToAddressNodeGen.java:247)
        from com.oracle.truffle.llvm.runtime.nodes.cast.LLVMToAddressNodeGen.executeGeneric_generic5(LLVMToAddressNodeGen.java:199)
        from com.oracle.truffle.llvm.runtime.nodes.cast.LLVMToAddressNodeGen.executeGeneric(LLVMToAddressNodeGen.java:87)
        from com.oracle.truffle.llvm.runtime.nodes.api.LLVMFrameNullerExpression.doGeneric(LLVMFrameNullerExpression.java:72)
        from com.oracle.truffle.llvm.runtime.nodes.api.LLVMFrameNullerExpressionNodeGen.executeGeneric(LLVMFrameNullerExpressionNodeGen.java:21)
        from com.oracle.truffle.llvm.runtime.nodes.vars.LLVMWriteNodeFactory$LLVMWritePointerNodeGen.execute_generic1(LLVMWriteNodeFactory.java:1031)
        from com.oracle.truffle.llvm.runtime.nodes.vars.LLVMWriteNodeFactory$LLVMWritePointerNodeGen.execute(LLVMWriteNodeFactory.java:1008)
        from com.oracle.truffle.llvm.runtime.nodes.base.LLVMBasicBlockNode$InitializedBlockNode.execute(LLVMBasicBlockNode.java:173)
        from com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNode.doDispatch(LLVMDispatchBasicBlockNode.java:97)
        from com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNodeGen.executeGeneric(LLVMDispatchBasicBlockNodeGen.java:24)
        from com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNode.doRun(LLVMFunctionRootNode.java:85)
        from com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNodeGen.executeGeneric(LLVMFunctionRootNodeGen.java:25)
        from com.oracle.truffle.llvm.runtime.nodes.func.LLVMFunctionStartNode.execute(LLVMFunctionStartNode.java:93)
        from org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:650)
        from /home/nvh0412/.rbenv/versions/truffleruby-21.3.0/lib/gems/bundler/gems/grpc-852dfdb82bbb/src/ruby/lib/grpc/generic/rpc_server.rb:234:in `initialize'
        from greeter_server.rb:39:in `main'
        from greeter_server.rb:48:in `<main>'

To reproduce:

Follow this issue to get patched grpc gem version

gem 'grpc', github: 'eregon/grpc', branch: 'truffleruby-debug', submodules: true

Verify that it's working

Screenshot from 2022-03-22 21-35-19

Get proto files

git clone https://github.com/grpc/grpc
cd examples/ruby
gem install grpc-tools
grpc_tools_ruby_protoc -I ./protos --ruby_out=lib --grpc_out=lib ./protos/helloworld.proto
bundle exec ruby greeter_server.rb
@eregon
Copy link
Member

eregon commented Mar 22, 2022

21.3 is not the last release, could you try 22.0 or dev builds as documented in the README?

grpc in general is not well supported yet (some details in #2611 (comment) and what follows).

@nvh0412
Copy link
Author

nvh0412 commented Mar 22, 2022

Dev builds doesn't work

Here is the error when I tried our latest dev build

➜  truffle-ruby bundle exec ruby -e 'require "grpc"'


truffleruby: an internal exception escaped out of the interpreter,
please report it to https://github.com/oracle/truffleruby/issues.

LLVMThreadLocalSymbol symbol: _ZN9grpc_core7ExecCtx9exec_ctx_E (java.lang.IllegalStateException)
        from com.oracle.truffle.llvm.runtime.CommonNodeFactory.createDebugStaticValue(CommonNodeFactory.java:461)
        from com.oracle.truffle.llvm.ParserDriver.lambda$createDebugInfo$4(ParserDriver.java:429)
        from com.oracle.truffle.llvm.ParserDriver$$Lambda$846e00f780c439ca5e981359c05f49f4fa5f1dea.accept(Unknown Source)
        from java.util.HashMap.forEach(HashMap.java:1337)
        from com.oracle.truffle.llvm.ParserDriver.createDebugInfo(ParserDriver.java:427)
        from com.oracle.truffle.llvm.ParserDriver.parseBinary(ParserDriver.java:371)
        from com.oracle.truffle.llvm.ParserDriver.parseLibraryWithSource(ParserDriver.java:449)
        from com.oracle.truffle.llvm.ParserDriver.parseWithDependencies(ParserDriver.java:145)
        from com.oracle.truffle.llvm.ParserDriver.parseWithDependencies(ParserDriver.java:131)
        from com.oracle.truffle.llvm.ParserDriver.parse(ParserDriver.java:104)
        from com.oracle.truffle.llvm.DefaultLoader.load(DefaultLoader.java:44)
        from com.oracle.truffle.llvm.runtime.LLVMLanguage.parse(LLVMLanguage.java:628)
        from com.oracle.truffle.api.TruffleLanguage$ParsingRequest.parse(TruffleLanguage.java:969)
        from com.oracle.truffle.api.TruffleLanguage.parse(TruffleLanguage.java:1326)
        from com.oracle.truffle.api.LanguageAccessor$LanguageImpl.parse(LanguageAccessor.java:292)
        from com.oracle.truffle.polyglot.PolyglotSourceCache.parseImpl(PolyglotSourceCache.java:94)
        from com.oracle.truffle.polyglot.PolyglotSourceCache$WeakCache.lookup(PolyglotSourceCache.java:222)
        from com.oracle.truffle.polyglot.PolyglotSourceCache.parseCached(PolyglotSourceCache.java:80)
        from com.oracle.truffle.polyglot.PolyglotLanguageContext.parseCached(PolyglotLanguageContext.java:369)
        from com.oracle.truffle.polyglot.EngineAccessor$EngineImpl.parseForLanguage(EngineAccessor.java:247)
        from com.oracle.truffle.api.TruffleLanguage$Env.parseInternal(TruffleLanguage.java:2251)
        from org.truffleruby.language.loader.FeatureLoader.loadCExtLibrary(FeatureLoader.java:505)
        from org.truffleruby.language.loader.RequireNode.requireCExtension(RequireNode.java:268)
        from org.truffleruby.language.loader.RequireNode.parseAndCall(RequireNode.java:217)
        from org.truffleruby.language.loader.RequireNode.doRequire(RequireNode.java:202)
        from org.truffleruby.language.loader.RequireNode.requireConsideringAutoload(RequireNode.java:126)
        from org.truffleruby.language.loader.RequireNode.lambda$requireWithMetrics$0(RequireNode.java:79)
        from org.truffleruby.language.loader.RequireNode$$Lambda$e54385dcb305ff68f57bf2cc513b32655fe4e7f0.get(Unknown Source)
        from org.truffleruby.debug.MetricsProfiler.callWithMetrics(MetricsProfiler.java:42)
        from org.truffleruby.language.loader.RequireNode.requireWithMetrics(RequireNode.java:76)
        from org.truffleruby.language.loader.RequireNode.require(RequireNode.java:68)
        from org.truffleruby.language.loader.RequireNodeGen.executeRequire(RequireNodeGen.java:31)
        from org.truffleruby.core.kernel.KernelNodes$LoadFeatureNode.loadFeature(KernelNodes.java:331)
        from org.truffleruby.core.kernel.KernelNodesFactory$LoadFeatureNodeFactory$LoadFeatureNodeGen.execute(KernelNodesFactory.java:830)
        from org.truffleruby.language.control.IfElseNode.execute(IfElseNode.java:43)
        from org.truffleruby.language.control.IfElseNode.execute(IfElseNode.java:45)
        from org.truffleruby.language.control.SequenceNode.execute(SequenceNode.java:36)
        from org.truffleruby.language.RubyMethodRootNode.execute(RubyMethodRootNode.java:65)
        from org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:659)
/home/nvh0412/.rbenv/versions/truffleruby-dev/lib/gems/bundler/gems/grpc-852dfdb82bbb/src/ruby/lib/grpc/grpc.rb:22:in `gem_original_require'
        from /home/nvh0412/.rbenv/versions/truffleruby-dev/lib/gems/bundler/gems/grpc-852dfdb82bbb/src/ruby/lib/grpc/grpc.rb:22:in `<top (required)>'
        from <internal:core> core/kernel.rb:293:in `require_relative'
        from /home/nvh0412/.rbenv/versions/truffleruby-dev/lib/gems/bundler/gems/grpc-852dfdb82bbb/src/ruby/lib/grpc.rb:19:in `<top (required)>'
        from <internal:core> core/kernel.rb:234:in `gem_original_require'
        from -e:1:in `<main>'

@nvh0412
Copy link
Author

nvh0412 commented Mar 22, 2022

As for 22.0.0.2 can boost the gRPC server

But the gRPC server raises the segment fault error right after I made a gRPC request from a client
Screenshot from 2022-03-22 22-27-23

@nvh0412
Copy link
Author

nvh0412 commented Mar 22, 2022

@eregon Dealing with the same situation with @jcoleman in this issue #2611, my system is heavy using gRPC. I want to give TruffleRuby a try before I make the decision that is we use TruffleRuby for current gRPC servers, but as we can see here, no luck with a repository and maintainers like gRPC repo

@eregon
Copy link
Member

eregon commented Mar 22, 2022

Thank you for trying the other versions.
The dev version error seems a regression, I'll report that to the GraalVM LLVM team (GR-37604).

Yes, grpc doesn't work yet on TruffleRuby.
As I mentioned in #2611 (comment) it's really difficult to make it work.
The fact grpc ruby maintainers are pretty unresponsive (even for fixes for CRuby) is not helping.

If I may ask, what do you use gRPC for? Is it for RPC between Ruby processes?

@nvh0412
Copy link
Author

nvh0412 commented Mar 22, 2022

Is it for RPC between Ruby processes?

Currently, yes. We applied micro-service architecture in the first place and now have many ruby apps in our clusters, pick up the right communication protocol between these microservices internally is one of most important thing and that's why we chose gRPC. We will have more services that will be written in other programming languages down the road

We're still fine with gRPC run under MRI, but there is a performance issue with multi-threaded gRPC server implementation (gRPC gem is using a thread-pool to handle requests), so giving TruffleRuby a try to archive a truly parallel

@eregon
Copy link
Member

eregon commented Apr 8, 2022

The error/regression LLVMThreadLocalSymbol symbol: _ZN9grpc_core7ExecCtx9exec_ctx_E (java.lang.IllegalStateException) (#2634 (comment)) has been fixed in Sulong, and the fix will be in 22.1 too. It will be in truffleruby dev builds next week.

@eregon
Copy link
Member

eregon commented Jun 28, 2022

This specific error has been fixed, so I'll close this.
I will use #2247 to track issues with using grpc at runtime.

@eregon eregon closed this as completed Jun 28, 2022
@eregon eregon added this to the 22.1.0 milestone Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants