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

Skip to content
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
8 changes: 6 additions & 2 deletions ext/ffi_c/Function.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,18 @@ static void
async_cb_dispatcher_mark(void *ptr)
{
struct async_cb_dispatcher *ctx = (struct async_cb_dispatcher *)ptr;
rb_gc_mark(ctx->thread);
if (ctx) {
rb_gc_mark(ctx->thread);
}
}

static void
async_cb_dispatcher_free(void *ptr)
{
struct async_cb_dispatcher *ctx = (struct async_cb_dispatcher *)ptr;
xfree(ctx);
if (ctx) {
xfree(ctx);
}
}

struct rb_ractor_local_storage_type async_cb_dispatcher_key_type = {
Expand Down
9 changes: 9 additions & 0 deletions spec/ffi/fork_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,14 @@ def run_async_callback(libtest)

expect(Process.wait2[1].exitstatus).to eq(44)
end

it "GC doesn't crash when the dispatcher thread was stopped. #1050" do
FFI::Function.new(:int, [], proc{})
fork do
GC.start
Process.exit 45
end
expect(Process.wait2[1].exitstatus).to eq(45)
end
end
end