1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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.
This commit is contained in:
卜部昌平 2021-01-20 10:26:49 +09:00
parent 7ccdad7be8
commit 0300dec32b
Notes: git 2021-01-27 09:30:42 +09:00
2 changed files with 9 additions and 27 deletions

View file

@ -1324,8 +1324,7 @@ define print_flags
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"

View file

@ -204,7 +204,7 @@ ruby_fl_type {
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()
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()
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()
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()