Cannot instanciate Http::Parser in Ractor
tagomoris opened this issue · 3 comments
tagomoris commented
The exception below happened:
Unexpected error: ractor unsafe method called from not main ractor
/Users/tagomoris/gh/right_speed/lib/right_speed/handler.rb:91:in `initialize'
/Users/tagomoris/gh/right_speed/lib/right_speed/handler.rb:91:in `new'
/Users/tagomoris/gh/right_speed/lib/right_speed/handler.rb:91:in `initialize'
/Users/tagomoris/gh/right_speed/lib/right_speed/handler.rb:12:in `new'
/Users/tagomoris/gh/right_speed/lib/right_speed/handler.rb:12:in `session'
/Users/tagomoris/gh/right_speed/lib/right_speed/worker/reader.rb:14:in `block in run'
Code called in a Ractor
@parser = Http::Parser.new(self)
Is that because Http::Parser
is a native-code library?
tagomoris commented
What is the "Ractor-safe" method? No documents https://docs.ruby-lang.org/en/master/Ractor.html
tagomoris commented
In the Ruby code, call_cfunc_*
functions always call ractor_unsafe_check();
at first, and it raises the exception if it's not in the main ractor.
tagomoris commented
We can use TracePoint's :c_call
event to find such method calls.