Project

General

Profile

Actions

Bug #21149

closed

Strange behavior of ObjectSpace.each_object after Ractor.new

Added by wanabe (_ wanabe) 3 days ago. Updated 2 days ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux]
[ruby-core:121121]

Description

I found the strange behavior of ObjectSpace.each_object.
It misses some objects after Ractor.new.

$ ruby -ve 'class Foo; end; foo = Foo.new; Ractor.new do buz = Foo.new end.take; bar = Foo.new; p [ObjectSpace.each_object(Foo).to_a, foo.class, bar.class]'
ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux]
-e:1: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
[[], Foo, Foo]

Of course it works well without Ractor.new.

$ ruby -ve 'class Foo; end; foo = Foo.new; bar = Foo.new; p [ObjectSpace.each_object(Foo).to_a, foo.class, bar.class]'
ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux]
[[#<Foo:0x00007fa84f4b26d0>, #<Foo:0x00007fa84f4b27c0>], Foo, Foo]

Related issues 3 (1 open2 closed)

Related to Ruby master - Feature #17270: ObjectSpace.each_object should be restricted on multi-RactorsClosedActions
Is duplicate of Ruby master - Bug #17360: Objects disappear from ObjectSpace after using RactorRejectedActions
Is duplicate of Ruby master - Bug #19387: Issue with ObjectSpace.each_objects not returning objects after starting a ractorAssignedko1 (Koichi Sasada)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0