ruby-changes:65053
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Wed, 27 Jan 2021 09:30:31 +0900 (JST)
Subject: [ruby-changes:65053] 0300dec32b (master): kill OBJ_TAINT etc.
https://git.ruby-lang.org/ruby.git/commit/?id=0300dec32b From 0300dec32b5a25b409dc5dfa59b81f4e39fab501 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: Wed, 20 Jan 2021 10:26:49 +0900 Subject: kill OBJ_TAINT etc. Now that RUBY_FL_TAINT is recycled to become new RUBY_FL_SHAREABLE. Setting/clearing this flag from extension libraries break Ractor. Especially problematic one is OBJ_INFECT, which would make non-shareable objects travel across Ractor boundaries. Such operations should just be prohibited. --- .gdbinit | 3 +-- include/ruby/internal/fl_type.h | 33 ++++++++------------------------- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/.gdbinit b/.gdbinit index 4938095..60aa8fb 100644 --- a/.gdbinit +++ b/.gdbinit @@ -1324,8 +1324,7 @@ define print_flags https://github.com/ruby/ruby/blob/trunk/.gdbinit#L1324 printf "RUBY_FL_PROMOTED0 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_PROMOTED0 ? "1" : "0" printf "RUBY_FL_PROMOTED1 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_PROMOTED1 ? "1" : "0" printf "RUBY_FL_FINALIZE : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_FINALIZE ? "1" : "0" - printf "RUBY_FL_TAINT : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_TAINT ? "1" : "0" - printf "RUBY_FL_UNTRUSTED : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_UNTRUSTED ? "1" : "0" + printf "RUBY_FL_SHAREABLE : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_SHAREABLE ? "1" : "0" printf "RUBY_FL_EXIVAR : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_EXIVAR ? "1" : "0" printf "RUBY_FL_FREEZE : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_FREEZE ? "1" : "0" diff --git a/include/ruby/internal/fl_type.h b/include/ruby/internal/fl_type.h index 9940036..01c1d2b 100644 --- a/include/ruby/internal/fl_type.h +++ b/include/ruby/internal/fl_type.h @@ -204,7 +204,7 @@ ruby_fl_type { https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/fl_type.h#L204 RUBY_FL_SINGLETON = RUBY_FL_USER0, }; -enum { RUBY_FL_DUPPED = RUBY_T_MASK | RUBY_FL_EXIVAR | RUBY_FL_TAINT }; +enum { RUBY_FL_DUPPED = RUBY_T_MASK | RUBY_FL_EXIVAR | RUBY_FL_SHAREABLE }; RBIMPL_SYMBOL_EXPORT_BEGIN() void rb_obj_infect(VALUE victim, VALUE carrier); @@ -362,18 +362,7 @@ RBIMPL_ATTR_ARTIFICIAL() https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/fl_type.h#L362 static inline bool RB_OBJ_TAINTABLE(VALUE obj) { - if (! RB_FL_ABLE(obj)) { - return false; - } - else if (RB_TYPE_P(obj, RUBY_T_BIGNUM)) { - return false; - } - else if (RB_TYPE_P(obj, RUBY_T_FLOAT)) { - return false; - } - else { - return true; - } + return false; } RBIMPL_ATTR_PURE_UNLESS_DEBUG() @@ -381,7 +370,7 @@ RBIMPL_ATTR_ARTIFICIAL() https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/fl_type.h#L370 static inline VALUE RB_OBJ_TAINTED_RAW(VALUE obj) { - return RB_FL_TEST_RAW(obj, RUBY_FL_TAINT); + return false; } RBIMPL_ATTR_PURE_UNLESS_DEBUG() @@ -389,41 +378,35 @@ RBIMPL_ATTR_ARTIFICIAL() https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/fl_type.h#L378 static inline bool RB_OBJ_TAINTED(VALUE obj) { - return RB_FL_ANY(obj, RUBY_FL_TAINT); + return false; } RBIMPL_ATTR_ARTIFICIAL() static inline void RB_OBJ_TAINT_RAW(VALUE obj) { - RB_FL_SET_RAW(obj, RUBY_FL_TAINT); + return; } RBIMPL_ATTR_ARTIFICIAL() static inline void RB_OBJ_TAINT(VALUE obj) { - if (RB_OBJ_TAINTABLE(obj)) { - RB_OBJ_TAINT_RAW(obj); - } + return; } RBIMPL_ATTR_ARTIFICIAL() static inline void RB_OBJ_INFECT_RAW(VALUE dst, VALUE src) { - RBIMPL_ASSERT_OR_ASSUME(RB_OBJ_TAINTABLE(dst)); - RBIMPL_ASSERT_OR_ASSUME(RB_FL_ABLE(src)); - RB_FL_SET_RAW(dst, RB_OBJ_TAINTED_RAW(src)); + return; } RBIMPL_ATTR_ARTIFICIAL() static inline void RB_OBJ_INFECT(VALUE dst, VALUE src) { - if (RB_OBJ_TAINTABLE(dst) && RB_FL_ABLE(src)) { - RB_OBJ_INFECT_RAW(dst, src); - } + return; } RBIMPL_ATTR_PURE_UNLESS_DEBUG() -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/