summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2023-01-03 10:50:40 -0500
committerPeter Zhu <peter@peterzhu.ca>2023-01-04 09:10:58 -0500
commit3bcf92d8afb62a10dd4c700a4925d2ccac43f5a2 (patch)
treeccc059757dd621f3de0d750e30e6134b979bdfb7 /gc.c
parent799d805e215e3bdcc2e9bbdb48638a129b50e8f4 (diff)
Allow malloc during gc when GC has been disabled
We should allow malloc during GC when GC has been explicitly disabled since garbage_collect_with_gvl won't do anything if GC has been disabled.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7058
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/gc.c b/gc.c
index d4f21f9a09..ef1f0adf69 100644
--- a/gc.c
+++ b/gc.c
@@ -9913,10 +9913,8 @@ gc_is_moveable_obj(rb_objspace_t *objspace, VALUE obj)
#define COULD_MALLOC_REGION_START() \
GC_ASSERT(during_gc); \
VALUE _already_disabled = rb_gc_disable_no_rest(); \
- during_gc = false;
#define COULD_MALLOC_REGION_END() \
- during_gc = true; \
if (_already_disabled == Qfalse) rb_objspace_gc_enable(objspace);
static VALUE
@@ -12216,7 +12214,7 @@ malloc_during_gc_p(rb_objspace_t *objspace)
* (since ractors can run while another thread is sweeping) and when we
* have the GVL (since if we don't have the GVL, we'll try to acquire the
* GVL which will block and ensure the other thread finishes GC). */
- return during_gc && !rb_multi_ractor_p() && ruby_thread_has_gvl_p();
+ return during_gc && !dont_gc_val() && !rb_multi_ractor_p() && ruby_thread_has_gvl_p();
}
static inline void *