summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ractor.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/ractor.c b/ractor.c
index 57c9c4178f..4322bf1246 100644
--- a/ractor.c
+++ b/ractor.c
@@ -71,7 +71,11 @@ ractor_lock(rb_ractor_t *r, const char *file, int line)
ASSERT_ractor_unlocking(r);
rb_native_mutex_lock(&r->sync.lock);
- r->malloc_gc_disabled = true;
+
+ if (rb_current_execution_context(false)) {
+ VM_ASSERT(!GET_RACTOR()->malloc_gc_disabled);
+ GET_RACTOR()->malloc_gc_disabled = true;
+ }
#if RACTOR_CHECK_MODE > 0
if (rb_current_execution_context(false) != NULL) {
@@ -101,9 +105,11 @@ ractor_unlock(rb_ractor_t *r, const char *file, int line)
r->sync.locked_by = Qnil;
#endif
- VM_ASSERT(r->malloc_gc_disabled);
+ if (rb_current_execution_context(false)) {
+ VM_ASSERT(GET_RACTOR()->malloc_gc_disabled);
+ GET_RACTOR()->malloc_gc_disabled = false;
+ }
- r->malloc_gc_disabled = false;
rb_native_mutex_unlock(&r->sync.lock);
RUBY_DEBUG_LOG2(file, line, "r:%u%s", r->pub.id, rb_current_ractor_raw(false) == r ? " (self)" : "");