Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ A lot of work has gone into making Ractors more stable, performant, and usable.
[Feature #21205]: https://bugs.ruby-lang.org/issues/21205
[Feature #21216]: https://bugs.ruby-lang.org/issues/21216
[Feature #21219]: https://bugs.ruby-lang.org/issues/21219
[Feature #21254]: https://bugs.ruby-lang.org/issues/21254
[Feature #21258]: https://bugs.ruby-lang.org/issues/21258
[Feature #21262]: https://bugs.ruby-lang.org/issues/21262
[Feature #21275]: https://bugs.ruby-lang.org/issues/21275
Expand Down
6 changes: 3 additions & 3 deletions bootstraptest/test_ractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ def ractor_local_globals
}

# ivar in shareable-objects are not allowed to access from non-main Ractor
assert_equal "can not get unshareable values from instance variables of classes/modules from non-main Ractors", <<~'RUBY', frozen_string_literal: false
assert_equal "can not get unshareable values from instance variables of classes/modules from non-main Ractors (@iv from C)", <<~'RUBY', frozen_string_literal: false
class C
@iv = 'str'
end
Expand Down Expand Up @@ -1022,7 +1022,7 @@ def initialize
}

# cvar in shareable-objects are not allowed to access from non-main Ractor
assert_equal 'can not access class variables from non-main Ractors', %q{
assert_equal 'can not access class variables from non-main Ractors (@@cv from C)', %q{
class C
@@cv = 'str'
end
Expand All @@ -1041,7 +1041,7 @@ class C
}

# also cached cvar in shareable-objects are not allowed to access from non-main Ractor
assert_equal 'can not access class variables from non-main Ractors', %q{
assert_equal 'can not access class variables from non-main Ractors (@@cv from C)', %q{
class C
@@cv = 'str'
def self.cv
Expand Down
7 changes: 7 additions & 0 deletions man/ruby.1
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,13 @@ variable is not defined, Ruby refers to
If set, Ruby tries to free all dynamically allocated memories.
Introduced in Ruby 3.3, default: unset.
.Pp
.It Ev RUBY_BOX
If set to
.Li 1 ,
Ruby Box is enabled and users will be able to execute
.Li Ruby::Box.new .
Ruby Box is an experimental feature introduced in Ruby 4.0.
.Pp
.It Ev RUBY_IO_BUFFER_DEFAULT_SIZE
The custom default buffer size of
.Li IO::Buffer .
Expand Down
16 changes: 9 additions & 7 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ VALUE rb_fs;
static inline const char *
search_nonascii(const char *p, const char *e)
{
const uintptr_t *s, *t;
const char *s, *t;

#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
# if SIZEOF_UINTPTR_T == 8
Expand Down Expand Up @@ -760,17 +760,19 @@ search_nonascii(const char *p, const char *e)
#define aligned_ptr(value) \
__builtin_assume_aligned((value), sizeof(uintptr_t))
#else
#define aligned_ptr(value) (uintptr_t *)(value)
#define aligned_ptr(value) (value)
#endif
s = aligned_ptr(p);
t = (uintptr_t *)(e - (SIZEOF_VOIDP-1));
t = (e - (SIZEOF_VOIDP-1));
#undef aligned_ptr
for (;s < t; s++) {
if (*s & NONASCII_MASK) {
for (;s < t; s += sizeof(uintptr_t)) {
uintptr_t word;
memcpy(&word, s, sizeof(word));
if (word & NONASCII_MASK) {
#ifdef WORDS_BIGENDIAN
return (const char *)s + (nlz_intptr(*s&NONASCII_MASK)>>3);
return (const char *)s + (nlz_intptr(word&NONASCII_MASK)>>3);
#else
return (const char *)s + (ntz_intptr(*s&NONASCII_MASK)>>3);
return (const char *)s + (ntz_intptr(word&NONASCII_MASK)>>3);
#endif
}
}
Expand Down
16 changes: 10 additions & 6 deletions variable.c
Original file line number Diff line number Diff line change
Expand Up @@ -1195,10 +1195,13 @@ IVAR_ACCESSOR_SHOULD_BE_MAIN_RACTOR(ID id)
}
}

#define CVAR_ACCESSOR_SHOULD_BE_MAIN_RACTOR() \
if (UNLIKELY(!rb_ractor_main_p())) { \
rb_raise(rb_eRactorIsolationError, "can not access class variables from non-main Ractors"); \
}
static void
CVAR_ACCESSOR_SHOULD_BE_MAIN_RACTOR(VALUE klass, ID id)
{
if (UNLIKELY(!rb_ractor_main_p())) {
rb_raise(rb_eRactorIsolationError, "can not access class variables from non-main Ractors (%"PRIsVALUE" from %"PRIsVALUE")", rb_id2str(id), klass);
}
}

static inline void
ivar_ractor_check(VALUE obj, ID id)
Expand Down Expand Up @@ -1444,7 +1447,8 @@ rb_ivar_lookup(VALUE obj, ID id, VALUE undef)
UNLIKELY(!rb_ractor_main_p()) &&
!rb_ractor_shareable_p(val)) {
rb_raise(rb_eRactorIsolationError,
"can not get unshareable values from instance variables of classes/modules from non-main Ractors");
"can not get unshareable values from instance variables of classes/modules from non-main Ractors (%"PRIsVALUE" from %"PRIsVALUE")",
rb_id2str(id), obj);
}
return val;
}
Expand Down Expand Up @@ -4202,7 +4206,7 @@ cvar_overtaken(VALUE front, VALUE target, ID id)
}

#define CVAR_LOOKUP(v,r) do {\
CVAR_ACCESSOR_SHOULD_BE_MAIN_RACTOR(); \
CVAR_ACCESSOR_SHOULD_BE_MAIN_RACTOR(klass, id); \
if (cvar_lookup_at(klass, id, (v))) {r;}\
CVAR_FOREACH_ANCESTORS(klass, v, r);\
} while(0)
Expand Down