Do not kick finalizers on rb_gc().

rb_gc() kicks gc_finalize_deferred(), which invokes finalizers.
This means that any Ruby program can be run this point and
it may be thread switching points and so on.

However, it is difficult to think it invokes any Ruby programs.
For example, `GC.compact` use `rb_gc()` to implement it, howver,
any Ruby program must not be run on this timing.

For this reason (it is difficult to image it run any Ruby program),
I removed `gc_finalize_deferred()` line in rb_gc().

This patch solves GC.compact issue.
[Bug #15809] and re-enable GC.compact test.
This commit is contained in:
Koichi Sasada 2019-05-23 11:21:16 +09:00
Родитель 0eff21af8d
Коммит 136ae55892
2 изменённых файлов: 5 добавлений и 4 удалений

7
gc.c
Просмотреть файл

@ -8171,7 +8171,11 @@ heap_check_moved_i(void *vstart, void *vend, size_t stride, void *data)
void *poisoned = poisoned_object_p(v);
unpoison_object(v, false);
if (BUILTIN_TYPE(v) != T_NONE) {
switch (BUILTIN_TYPE(v)) {
case T_NONE:
case T_ZOMBIE:
break;
default:
rb_objspace_reachable_objects_from(v, reachable_object_check_moved_i, (void *)v);
}
@ -8309,7 +8313,6 @@ rb_gc(void)
int reason = GPR_FLAG_FULL_MARK | GPR_FLAG_IMMEDIATE_MARK |
GPR_FLAG_IMMEDIATE_SWEEP | GPR_FLAG_CAPI;
garbage_collect(objspace, reason);
gc_finalize_deferred(objspace);
}
int

Просмотреть файл

@ -2,8 +2,6 @@
require 'test/unit'
require 'fiddle'
return
class TestGCCompact < Test::Unit::TestCase
def memory_location(obj)
(Fiddle.dlwrap(obj) >> 1)