mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
guard rb_fatal against non-GVL call
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.
This commit is contained in:
parent
f1ce4897f2
commit
2d393bf125
1 changed files with 8 additions and 0 deletions
8
error.c
8
error.c
|
@ -2668,6 +2668,14 @@ rb_fatal(const char *fmt, ...)
|
||||||
va_list args;
|
va_list args;
|
||||||
VALUE mesg;
|
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);
|
va_start(args, fmt);
|
||||||
mesg = rb_vsprintf(fmt, args);
|
mesg = rb_vsprintf(fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
Loading…
Add table
Reference in a new issue