[前][次][番号順一覧][スレッド一覧]

ruby-changes:63749

From: Koichi <ko1@a...>
Date: Wed, 25 Nov 2020 15:08:46 +0900 (JST)
Subject: [ruby-changes:63749] a79fe07db6 (master): show the error message before Ractor.yield

https://git.ruby-lang.org/ruby.git/commit/?id=a79fe07db6

From a79fe07db6c2de7a477613f8cd5c9c51322367bf Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Wed, 25 Nov 2020 15:00:26 +0900
Subject: show the error message before Ractor.yield

Ractor's error will be printed if Thread#report_on_exception
is true (default), and error message is used. Without this patch,
the exception object is sent by Ractor.yield and it can be shared
with another ractor.

http://ci.rvm.jp/results/trunk-random3@phosphorus-docker/3269368

To prevent such sharing, show errors befor Ractor.yield().

diff --git a/thread.c b/thread.c
index 6747376..964f432 100644
--- a/thread.c
+++ b/thread.c
@@ -831,18 +831,19 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start) https://github.com/ruby/ruby/blob/trunk/thread.c#L831
 		/* exit on main_thread. */
 	    }
 	    else {
-                if (th->invoke_type == thread_invoke_type_ractor_proc) {
-                    rb_ractor_atexit_exception(th->ec);
-                }
-
                 if (th->report_on_exception) {
 		    VALUE mesg = rb_thread_to_s(th->self);
 		    rb_str_cat_cstr(mesg, " terminated with exception (report_on_exception is true):\n");
 		    rb_write_error_str(mesg);
 		    rb_ec_error_print(th->ec, errinfo);
 		}
-		if (th->vm->thread_abort_on_exception ||
-		    th->abort_on_exception || RTEST(ruby_debug)) {
+
+                if (th->invoke_type == thread_invoke_type_ractor_proc) {
+                    rb_ractor_atexit_exception(th->ec);
+                }
+
+                if (th->vm->thread_abort_on_exception ||
+                    th->abort_on_exception || RTEST(ruby_debug)) {
 		    /* exit on main_thread */
 		}
 		else {
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]