Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Don't copy RUBY_FL_PROMOTED flag in rb_obj_setup #9349

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

Merged
merged 1 commit into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion object.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ rb_obj_reveal(VALUE obj, VALUE klass)
VALUE
rb_obj_setup(VALUE obj, VALUE klass, VALUE type)
{
RBASIC(obj)->flags = type;
VALUE ignored_flags = RUBY_FL_PROMOTED;
RBASIC(obj)->flags = (type & ~ignored_flags) | (RBASIC(obj)->flags & ignored_flags);
RBASIC_SET_CLASS(obj, klass);
return obj;
}
Expand Down
11 changes: 11 additions & 0 deletions test/ruby/test_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,17 @@ def m.bar; :bar; end
assert_equal(:bar, m.clone.bar)
end

def test_clone_under_gc_compact_stress
EnvUtil.under_gc_compact_stress do
o = Object.new
def o.foo; :foo; end
m = o.method(:foo)
def m.bar; :bar; end
assert_equal(:foo, m.clone.call)
assert_equal(:bar, m.clone.bar)
end
end

def test_inspect
o = Object.new
def o.foo; end; line_no = __LINE__
Expand Down