Project

General

Profile

Actions

Bug #17477

closed

Ractor and pp incompatibility

Bug #17477: Ractor and pp incompatibility

Added by kirs (Kir Shatrov) almost 5 years ago. Updated almost 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:101731]

Description

r = Ractor.new do
  pp("foobar")
end
Ractor.select(r)

fails with:

#<Thread:0x00007f973414a050 run> terminated with exception (report_on_exception is true):
<internal:/opt/rubies/3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:164:in `ensure in require': can not access non-shareable objects in constant Kernel::RUBYGEMS_ACTIVATION_MONITOR by non-main ractor. (Ractor::IsolationError)
	from <internal:/opt/rubies/3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:167:in `require'
	from notractor.rb:8:in `block in <main>'
<internal:/opt/rubies/3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:37:in `require': can not access non-shareable objects in constant Kernel::RUBYGEMS_ACTIVATION_MONITOR by non-main ractor. (Ractor::IsolationError)
	from notractor.rb:8:in `block in <main>'
<internal:ractor>:345:in `select': thrown by remote Ractor. (Ractor::RemoteError)
	from notractor.rb:11:in `<main>'
<internal:/opt/rubies/3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:164:in `ensure in require': can not access non-shareable objects in constant Kernel::RUBYGEMS_ACTIVATION_MONITOR by non-main ractor. (Ractor::IsolationError)
	from <internal:/opt/rubies/3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:167:in `require'
	from notractor.rb:8:in `block in <main>'
<internal:/opt/rubies/3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:37:in `require': can not access non-shareable objects in constant Kernel::RUBYGEMS_ACTIVATION_MONITOR by non-main ractor. (Ractor::IsolationError)
	from notractor.rb:8:in `block in <main>'

This is easy to fix by calling require 'pp' in the top from the main Ractor - but I don't think it is expected for developers. We should optimize for developer's happiness and either make it just work or make it clear that everything should be required beforehand.


Related issues 1 (0 open1 closed)

Related to Ruby - Bug #17420: Unsafe mutation of $" when doing non-RubyGems require in RactorClosedractorActions

Updated by Eregon (Benoit Daloze) almost 5 years ago Actions #1

  • Related to Bug #17420: Unsafe mutation of $" when doing non-RubyGems require in Ractor added

Updated by Eregon (Benoit Daloze) almost 5 years ago Actions #2 [ruby-core:101749]

I doubt require can ever be supported in a Ractor, see #17420.

It seems there is no good solution for this, and besides this problem not only happens with pp but with any kind of "autoloaded" library/gem.

Updated by duerst (Martin Dürst) almost 5 years ago Actions #3 [ruby-core:101766]

My preference would be to make require work everywhere, but always be executed in the main Reactor. That would just be part of the semantics of require.

Updated by marcandre (Marc-Andre Lafortune) almost 5 years ago Actions #4 [ruby-core:101769]

I wrote a similar opinion to Martin Dürst's in #17420. I propose that we comment there (simply because the issue is older and more general)

Updated by kirs (Kir Shatrov) almost 5 years ago Actions #5 [ruby-core:101805]

marcandre (Marc-Andre Lafortune) wrote in #note-4:

I wrote a similar opinion to Martin Dürst's in #17420. I propose that we comment there (simply because the issue is older and more general)

Thanks, I wasn't aware of #17420. Should I close this ticket?

Updated by ko1 (Koichi Sasada) almost 5 years ago Actions #6 [ruby-core:101921]

  • Status changed from Open to Closed

continue to discuss on #17420.

Actions

Also available in: PDF Atom