Skip to content

Commit a1c2228

Browse files
committed
Non-zero exit when error in loading shared GC
Before this commit, when there is an error in loading the shared GC, an error was outputted but it did not exit, causing it to segfault later on.
1 parent 8024454 commit a1c2228

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

gc.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,6 @@ static rb_gc_function_map_t rb_gc_functions;
648648

649649
# define RUBY_GC_LIBRARY "RUBY_GC_LIBRARY"
650650

651-
# define fatal(...) do {fprintf(stderr, "" __VA_ARGS__); return;} while (0)
652-
653651
static void
654652
ruby_external_gc_init(void)
655653
{
@@ -672,7 +670,8 @@ ruby_external_gc_init(void)
672670
case '.':
673671
break;
674672
default:
675-
fatal("Only alphanumeric, dash, underscore, and period is allowed in "RUBY_GC_LIBRARY"");
673+
fprintf(stderr, "Only alphanumeric, dash, underscore, and period is allowed in "RUBY_GC_LIBRARY"\n");
674+
exit(1);
676675
}
677676
}
678677

@@ -682,7 +681,8 @@ ruby_external_gc_init(void)
682681

683682
handle = dlopen(gc_so_path, RTLD_LAZY | RTLD_GLOBAL);
684683
if (!handle) {
685-
fatal("ruby_external_gc_init: Shared library %s cannot be opened: %s", gc_so_path, dlerror());
684+
fprintf(stderr, "ruby_external_gc_init: Shared library %s cannot be opened: %s\n", gc_so_path, dlerror());
685+
exit(1);
686686
}
687687
}
688688

@@ -692,7 +692,8 @@ ruby_external_gc_init(void)
692692
if (handle) { \
693693
gc_functions.name = dlsym(handle, "rb_gc_impl_" #name); \
694694
if (!gc_functions.name) { \
695-
fatal("ruby_external_gc_init: " #name " func not exported by library %s", gc_so_path); \
695+
fprintf(stderr, "ruby_external_gc_init: " #name " func not exported by library %s\n", gc_so_path); \
696+
exit(1); \
696697
} \
697698
} \
698699
else { \

0 commit comments

Comments
 (0)