Skip to content

Commit eedb30d

Browse files
committed
Use rb_gc_enable/rb_gc_disable_no_rest instead of ruby_disable_gc
We should use the rb_gc_enable/rb_gc_disable_no_rest APIs instead of directly setting the ruby_disable_gc variable.
1 parent d4fb966 commit eedb30d

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

gc/default/default.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,6 @@ struct RZombie {
983983

984984
#define RZOMBIE(o) ((struct RZombie *)(o))
985985

986-
int ruby_disable_gc = 0;
987986
int ruby_enable_autocompact = 0;
988987
#if RGENGC_CHECK_MODE
989988
gc_compact_compare_func ruby_autocompact_compare_func;
@@ -6264,7 +6263,7 @@ heap_ready_to_gc(rb_objspace_t *objspace, rb_heap_t *heap)
62646263
static int
62656264
ready_to_gc(rb_objspace_t *objspace)
62666265
{
6267-
if (dont_gc_val() || during_gc || ruby_disable_gc) {
6266+
if (dont_gc_val() || during_gc) {
62686267
for (int i = 0; i < HEAP_COUNT; i++) {
62696268
rb_heap_t *heap = &heaps[i];
62706269
heap_ready_to_gc(objspace, heap);

internal/gc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ struct rb_objspace; /* in vm_core.h */
175175
if (_already_disabled == Qfalse) rb_gc_enable()
176176

177177
/* gc.c */
178-
extern int ruby_disable_gc;
179178
RUBY_ATTR_MALLOC void *ruby_mimmalloc(size_t size);
180179
RUBY_ATTR_MALLOC void *ruby_mimcalloc(size_t num, size_t size);
181180
void ruby_mimfree(void *ptr);

signal.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,10 @@ rb_get_next_signal(void)
751751

752752
#if defined SIGSEGV || defined SIGBUS || defined SIGILL || defined SIGFPE
753753
static const char *received_signal;
754-
# define clear_received_signal() (void)(ruby_disable_gc = 0, received_signal = 0)
754+
# define clear_received_signal() do { \
755+
if (GET_VM() != NULL) rb_gc_enable(); \
756+
received_signal = 0; \
757+
} while (0)
755758
#else
756759
# define clear_received_signal() ((void)0)
757760
#endif
@@ -1001,7 +1004,9 @@ check_reserved_signal_(const char *name, size_t name_len, int signo)
10011004
ruby_abort();
10021005
}
10031006

1004-
ruby_disable_gc = 1;
1007+
if (GET_VM() != NULL) {
1008+
rb_gc_disable_no_rest();
1009+
}
10051010
}
10061011
#endif
10071012

0 commit comments

Comments
 (0)