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

Do not check pending interrupts when running finalizers #4366

Merged
merged 1 commit into from Jul 29, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions gc.c
Expand Up @@ -4088,10 +4088,14 @@ static void
finalize_deferred(rb_objspace_t *objspace)
{
VALUE zombie;
rb_execution_context_t *ec = GET_EC();
ec->interrupt_mask |= PENDING_INTERRUPT_MASK;

while ((zombie = ATOMIC_VALUE_EXCHANGE(heap_pages_deferred_final, 0)) != 0) {
finalize_list(objspace, zombie);
}

ec->interrupt_mask &= ~PENDING_INTERRUPT_MASK;
}

static void
Expand Down
25 changes: 25 additions & 0 deletions test/ruby/test_objectspace.rb
Expand Up @@ -168,6 +168,31 @@ def test_exception_in_finalizer
end;
end

def test_finalizer_thread_raise
GC.disable
fzer = proc do |id|
sleep 0.2
end
2.times do
o = Object.new
ObjectSpace.define_finalizer(o, fzer)
end

my_error = Class.new(RuntimeError)
begin
main_th = Thread.current
Thread.new do
sleep 0.1
main_th.raise(my_error)
end
GC.start
puts "After GC"
sleep(10)
assert(false)
rescue my_error
end
end

def test_each_object
klass = Class.new
new_obj = klass.new
Expand Down