ruby-changes:58195
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Thu, 10 Oct 2019 18:05:02 +0900 (JST)
Subject: [ruby-changes:58195] 2d393bf125 (master): guard rb_fatal against non-GVL call
https://git.ruby-lang.org/ruby.git/commit/?id=2d393bf125 From 2d393bf1255864706cabdd9375dd26e33bdf40b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Thu, 10 Oct 2019 17:49:31 +0900 Subject: 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. diff --git a/error.c b/error.c index 0c3633c..fa750e2 100644 --- a/error.c +++ b/error.c @@ -2668,6 +2668,14 @@ rb_fatal(const char *fmt, ...) https://github.com/ruby/ruby/blob/trunk/error.c#L2668 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); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/