Skip to content

Commit

Permalink
guard rb_fatal against non-GVL call
Browse files Browse the repository at this point in the history
Suggested by ko1.  rb_fatal requires GVL so just in case one lacks,
print that information and let the process die.  As commented,
we cannot print the given messages on such situations.
  • Loading branch information
shyouhei committed Oct 10, 2019
1 parent f1ce489 commit 2d393bf
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions error.c
Original file line number Diff line number Diff line change
Expand Up @@ -2668,6 +2668,14 @@ rb_fatal(const char *fmt, ...)
va_list args;
VALUE mesg;

if (! ruby_thread_has_gvl_p()) {
/* The thread has no GVL. Object allocation impossible (cant run GC),
* thus no message can be printed out. */
fprintf(stderr, "[FATAL] rb_fatal() outside of GVL\n");
rb_print_backtrace();
die();
}

va_start(args, fmt);
mesg = rb_vsprintf(fmt, args);
va_end(args);
Expand Down

0 comments on commit 2d393bf

Please sign in to comment.