From 8247b8eddeb2a504a5c9776d1f77d413c8146897 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Tue, 1 Dec 2020 11:14:36 +0900 Subject: should not use rb_ary_modify() ractor_copy() used rb_ary_modify() to make sure this array is not sharing anything, but it also checks frozen flag. So frozen arrays raises an error. To solve this issue, this patch introduces new function rb_ary_cancel_sharing() which makes sure the array does not share another array and it doesn't check frozen flag. [Bug #17343] A test is quoted from https://github.com/ruby/ruby/pull/3817 --- ractor.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ractor.c') diff --git a/ractor.c b/ractor.c index 4a75b41fc5..693bbe274d 100644 --- a/ractor.c +++ b/ractor.c @@ -2314,7 +2314,7 @@ obj_traverse_replace_i(VALUE obj, struct obj_traverse_replace_data *data) case T_ARRAY: { - rb_ary_modify(obj); + rb_ary_cancel_sharing(obj); #if USE_TRANSIENT_HEAP if (data->move) rb_ary_transient_heap_evacuate(obj, TRUE); #endif @@ -2537,7 +2537,8 @@ copy_leave(VALUE obj, struct obj_traverse_replace_data *data) return traverse_cont; } -static VALUE ractor_copy(VALUE obj) +static VALUE +ractor_copy(VALUE obj) { VALUE val = rb_obj_traverse_replace(obj, copy_enter, copy_leave, false); if (val != Qundef) { -- cgit v1.2.3