ruby-changes:65047
From: Matt <ko1@a...>
Date: Wed, 27 Jan 2021 01:18:20 +0900 (JST)
Subject: [ruby-changes:65047] 479e4d13cb (master): Fix RGENGC CHECK MODE >= 4
https://git.ruby-lang.org/ruby.git/commit/?id=479e4d13cb From 479e4d13cbf0bf2c7d3789787a8c055468141e4f Mon Sep 17 00:00:00 2001 From: Matt Valentine-House <matt@e...> Date: Thu, 14 Jan 2021 21:33:02 +0000 Subject: Fix RGENGC CHECK MODE >= 4 [A previous commit](b59077eecf912a16efefc0256f6e94a000ce3888) removes some macro definitions that are used when RGENGC_CHECK_MODE >=4 because they were using data stored against objspace, which is not ractor safe This commit reinstates those macro definitions, using the current ractor Co-authored-by: peterzhu2118 <peter@p...> --- gc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gc.c b/gc.c index c6bc641..9bee246 100644 --- a/gc.c +++ b/gc.c @@ -6729,12 +6729,17 @@ allrefs_roots_i(VALUE obj, void *ptr) https://github.com/ruby/ruby/blob/trunk/gc.c#L6729 push_mark_stack(&data->mark_stack, obj); } } +#define PUSH_MARK_FUNC_DATA(v) do { \ + struct gc_mark_func_data_struct *prev_mark_func_data = GET_RACTOR()->mfd; \ + GET_RACTOR()->mfd = (v); + +#define POP_MARK_FUNC_DATA() GET_RACTOR()->mfd = prev_mark_func_data;} while (0) static st_table * objspace_allrefs(rb_objspace_t *objspace) { struct allrefs data; - struct mark_func_data_struct mfd; + struct gc_mark_func_data_struct mfd; VALUE obj; int prev_dont_gc = dont_gc_val(); dont_gc_on(); @@ -6748,7 +6753,7 @@ objspace_allrefs(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L6753 /* traverse root objects */ PUSH_MARK_FUNC_DATA(&mfd); - objspace->mark_func_data = &mfd; + GET_RACTOR()->mfd = &mfd; gc_mark_roots(objspace, &data.category); POP_MARK_FUNC_DATA(); -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/