diff options
author | NARUSE, Yui <[email protected]> | 2021-02-08 19:13:52 +0900 |
---|---|---|
committer | NARUSE, Yui <[email protected]> | 2021-02-08 19:13:52 +0900 |
commit | 9aba46d8d80473594e567dff1652626e7b2a77b0 (patch) | |
tree | 5a5bf0d45e6874414fad875f8144dc8dad44be7d | |
parent | 6e8e7005724e9b67a80ca0bcf455aa1c8bef31cf (diff) |
merge revision(s) 6f727853cee41195b67ee5d793c1ac23fe1a6ae0,b2674c1fd725b43adf51af7935c780359d70c2a4: [Backport #17482]
only main thread can modify vm->ubf_async_safe
vm->ubf_async_safe is VM global resource and only main thread
can manipulate it.
[Bug #17482]
---
thread.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
unblock thread is only for main ractor.
other ractors should not have a unblock thread.
This patch fixes 6f727853cee41195b67ee5d793c1ac23fe1a6ae0.
---
thread.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
-rw-r--r-- | thread.c | 8 | ||||
-rw-r--r-- | version.h | 4 |
2 files changed, 7 insertions, 5 deletions
@@ -1650,6 +1650,8 @@ rb_nogvl(void *(*func)(void *), void *data1, void *val = 0; rb_execution_context_t *ec = GET_EC(); rb_thread_t *th = rb_ec_thread_ptr(ec); + rb_vm_t *vm = rb_ec_vm_ptr(ec); + bool is_main_thread = vm->ractor.main_thread == th; int saved_errno = 0; VALUE ubf_th = Qfalse; @@ -1657,9 +1659,9 @@ rb_nogvl(void *(*func)(void *), void *data1, ubf = ubf_select; data2 = th; } - else if (ubf && rb_ractor_living_thread_num(th->ractor) == 1) { + else if (ubf && rb_ractor_living_thread_num(th->ractor) == 1 && is_main_thread) { if (flags & RB_NOGVL_UBF_ASYNC_SAFE) { - th->vm->ubf_async_safe = 1; + vm->ubf_async_safe = 1; } else { ubf_th = rb_thread_start_unblock_thread(); @@ -1671,7 +1673,7 @@ rb_nogvl(void *(*func)(void *), void *data1, saved_errno = errno; }, ubf, data2, flags & RB_NOGVL_INTR_FAIL); - th->vm->ubf_async_safe = 0; + if (is_main_thread) vm->ubf_async_safe = 0; if ((flags & RB_NOGVL_INTR_FAIL) == 0) { RUBY_VM_CHECK_INTS_BLOCKING(ec); @@ -12,11 +12,11 @@ # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 0 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 38 +#define RUBY_PATCHLEVEL 40 #define RUBY_RELEASE_YEAR 2021 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 7 +#define RUBY_RELEASE_DAY 8 #include "ruby/version.h" |