diff options
author | KJ Tsanaktsidis <ktsanaktsidis@zendesk.com> | 2023-11-07 22:08:34 +1100 |
---|---|---|
committer | Jean Boussier <jean.boussier@gmail.com> | 2023-11-12 17:50:37 +0100 |
commit | 9a62fd3cbae2ebb60e2f9cad782af1ad18db4319 (patch) | |
tree | e647e33b74ca3b4731322aa9d60f1ec5d161b2d0 /gc.c | |
parent | 76dc327eeffefe02577999fe5f8215f762a581b6 (diff) |
Fix crash caused by concurrent ObjectSpace.dump_all calls
Since the callback defined in the objspace module might give up the GVL,
we need to make sure the right cr->mfd value is set back after the GVL
is re-obtained.
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -11935,7 +11935,11 @@ static void reachable_objects_from_callback(VALUE obj) { rb_ractor_t *cr = GET_RACTOR(); - cr->mfd->mark_func(obj, cr->mfd->data); + struct gc_mark_func_data_struct *cur_mfd = cr->mfd; + cur_mfd->mark_func(obj, cr->mfd->data); + /* mark_func might give up the GVL, in which time some other thread might set + mfd. In that case, set it back to the right value for this thread. */ + cr->mfd = cur_mfd; } void |