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
5 changes: 3 additions & 2 deletions enumerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <float.h>
#endif

#include <limits.h>
#include "id.h"
#include "internal.h"
#include "internal/class.h"
Expand Down Expand Up @@ -4008,7 +4009,7 @@ arith_seq_take(VALUE self, VALUE num)
ary = rb_ary_new_capa((n < len) ? n : len);
while (n > 0 && i < end) {
rb_ary_push(ary, LONG2FIX(i));
if (i + unit < i) break;
if (i > LONG_MAX - unit) break;
i += unit;
--n;
}
Expand All @@ -4021,7 +4022,7 @@ arith_seq_take(VALUE self, VALUE num)
ary = rb_ary_new_capa((n < len) ? n : len);
while (n > 0 && i > end) {
rb_ary_push(ary, LONG2FIX(i));
if (i + unit > i) break;
if (i < LONG_MIN - unit) break;
i += unit;
--n;
}
Expand Down
4 changes: 2 additions & 2 deletions ext/-test-/stack/stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "internal/string.h"

static VALUE
stack_alloca_overflow(VALUE self)
stack_overflow(VALUE self)
{
size_t i = 0;

Expand Down Expand Up @@ -30,6 +30,6 @@ asan_p(VALUE klass)
void
Init_stack(VALUE klass)
{
rb_define_singleton_method(rb_cThread, "alloca_overflow", stack_alloca_overflow, 0);
rb_define_singleton_method(rb_cThread, "stack_overflow", stack_overflow, 0);
rb_define_singleton_method(rb_cThread, "asan?", asan_p, 0);
}
9 changes: 9 additions & 0 deletions gc/mmtk/mmtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ RB_THREAD_LOCAL_SPECIFIER VALUE marking_parent_object;
# error We currently need language-supported TLS
#endif

#ifdef MMTK_DEBUG
# define MMTK_ASSERT(expr, ...) RUBY_ASSERT_ALWAYS(expr, #expr RBIMPL_VA_OPT_ARGS(__VA_ARGS__))
#else
# define MMTK_ASSERT(expr, ...) ((void)0)
#endif

#include <pthread.h>

static void
Expand Down Expand Up @@ -975,6 +981,9 @@ rb_gc_impl_writebarrier(void *objspace_ptr, VALUE a, VALUE b)
}
#endif

MMTK_ASSERT(BUILTIN_TYPE(a) != T_NONE);
MMTK_ASSERT(BUILTIN_TYPE(b) != T_NONE);

mmtk_object_reference_write_post(cache->mutator, (MMTk_ObjectReference)a);
}

Expand Down
6 changes: 3 additions & 3 deletions test/-ext-/stack/test_stack_overflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_overflow
require '-test-/stack'

assert_raise(SystemStackError) do
Thread.alloca_overflow
Thread.stack_overflow
end
RUBY
end
Expand All @@ -29,7 +29,7 @@ def test_thread_stack_overflow

thread = Thread.new do
Thread.current.report_on_exception = false
Thread.alloca_overflow
Thread.stack_overflow
end

assert_raise(SystemStackError) do
Expand All @@ -44,7 +44,7 @@ def test_fiber_stack_overflow
GC.disable

fiber = Fiber.new do
Thread.alloca_overflow
Thread.stack_overflow
end

assert_raise(SystemStackError) do
Expand Down
2 changes: 1 addition & 1 deletion test/-ext-/tracepoint/test_tracepoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def run(hook)
end

def test_teardown_with_active_GC_end_hook
assert_separately([], 'require("-test-/tracepoint"); Bug.after_gc_exit_hook = proc {}; GC.start')
assert_ruby_status([], 'require("-test-/tracepoint"); Bug.after_gc_exit_hook = proc {}; GC.start')
end

end
4 changes: 2 additions & 2 deletions test/objspace/test_objspace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def test_reachable_objects_from
def test_reachable_objects_during_iteration
omit 'flaky on Visual Studio with: [BUG] Unnormalized Fixnum value' if /mswin/ =~ RUBY_PLATFORM
opts = %w[--disable-gem --disable=frozen-string-literal -robjspace]
assert_separately opts, "#{<<-"begin;"}\n#{<<-'end;'}"
assert_ruby_status opts, "#{<<-"begin;"}\n#{<<-'end;'}"
begin;
ObjectSpace.each_object{|o|
o.inspect
Expand Down Expand Up @@ -179,7 +179,7 @@ def test_reachable_objects_size
end

def test_trace_object_allocations_stop_first
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
assert_ruby_status([], "#{<<~"begin;"}\n#{<<~'end;'}")
begin;
require "objspace"
# Make sure stopping before the tracepoints are initialized doesn't raise. See [Bug #17020]
Expand Down
2 changes: 1 addition & 1 deletion test/openssl/test_fips.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_fips_mode_get_is_false_on_fips_mode_disabled
def test_fips_mode_is_reentrant
return if aws_lc? # AWS-LC's FIPS mode is decided at compile time.

assert_separately(["-ropenssl"], <<~"end;")
assert_ruby_status(["-ropenssl"], <<~"end;")
OpenSSL.fips_mode = false
OpenSSL.fips_mode = false
end;
Expand Down
1 change: 1 addition & 0 deletions test/ripper/assert_parse_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Parser < Ripper
end
}
end
assert(true) if scripts.empty?
end;
end
end
8 changes: 6 additions & 2 deletions test/ruby/test_autoload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ def test_autoload_parallel_race
autoload_path = File.join(tmpdir, "autoload_parallel_race.rb")
File.write(autoload_path, 'module Foo; end; module Bar; end')

assert_separately([], <<-RUBY, timeout: 100)
assert_ruby_status([], <<-RUBY, timeout: 100)
autoload_path = #{File.realpath(autoload_path).inspect}

# This should work with no errors or failures.
Expand Down Expand Up @@ -617,6 +617,10 @@ module SomeNamespace
private

def assert_separately(*args, **kwargs)
super(*args, **{ timeout: 60 }.merge(kwargs))
super(*args, timeout: 60, **kwargs)
end

def assert_ruby_status(*args, **kwargs)
super(*args, timeout: 60, **kwargs)
end
end
2 changes: 1 addition & 1 deletion test/ruby/test_gc_compact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def add_ivars
def test_compact_objects_of_varying_sizes
omit if GC::INTERNAL_CONSTANTS[:SIZE_POOL_COUNT] == 1

assert_separately([], "#{<<~"begin;"}\n#{<<~"end;"}", timeout: 10)
assert_ruby_status([], "#{<<~"begin;"}\n#{<<~"end;"}", timeout: 10)
begin;
$objects = []
160.times do |n|
Expand Down
2 changes: 1 addition & 1 deletion test/ruby/test_lambda.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def self.b
end

def test_proc_inside_lambda_toplevel
assert_separately [], <<~RUBY
assert_ruby_status [], <<~RUBY
lambda{
$g = proc{ return :pr }
}.call
Expand Down
4 changes: 2 additions & 2 deletions test/ruby/test_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ def b; 2 end
end

def test_gc_prepend_chain
assert_separately([], <<-EOS)
assert_ruby_status([], <<-EOS)
10000.times { |i|
m1 = Module.new do
def foo; end
Expand Down Expand Up @@ -3073,7 +3073,7 @@ def test_return_value_of_define_singleton_method
end

def test_prepend_gc
assert_separately [], %{
assert_ruby_status [], %{
module Foo
end
class Object
Expand Down
12 changes: 9 additions & 3 deletions test/ruby/test_optimization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -946,14 +946,14 @@ def foo &b
end

def test_peephole_optimization_without_trace
assert_separately [], <<-END
assert_ruby_status [], <<-END
RubyVM::InstructionSequence.compile_option = {trace_instruction: false}
eval "def foo; 1.times{|(a), &b| nil && a}; end"
END
end

def test_clear_unreachable_keyword_args
assert_separately [], <<-END, timeout: 60
assert_ruby_status [], <<-END, timeout: 60
script = <<-EOS
if true
else
Expand Down Expand Up @@ -1080,7 +1080,7 @@ def test_optimized_rescue
class Objtostring
end

def test_objtostring
def test_objtostring_immediate
assert_raise(NoMethodError){"#{BasicObject.new}"}
assert_redefine_method('Symbol', 'to_s', <<-'end')
assert_match %r{\A#<Symbol:0x[0-9a-f]+>\z}, "#{:foo}"
Expand All @@ -1094,11 +1094,17 @@ def test_objtostring
assert_redefine_method('FalseClass', 'to_s', <<-'end')
assert_match %r{\A#<FalseClass:0x[0-9a-f]+>\z}, "#{false}"
end
end

def test_objtostring_fixnum
assert_redefine_method('Integer', 'to_s', <<-'end')
(-1..10).each { |i|
assert_match %r{\A#<Integer:0x[0-9a-f]+>\z}, "#{i}"
}
end
end

def test_objtostring
assert_equal "TestRubyOptimization::Objtostring", "#{Objtostring}"
assert_match %r{\A#<Class:0x[0-9a-f]+>\z}, "#{Class.new}"
assert_match %r{\A#<Module:0x[0-9a-f]+>\z}, "#{Module.new}"
Expand Down
4 changes: 2 additions & 2 deletions test/ruby/test_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1996,7 +1996,7 @@ def test_popen_exit
end

def test_popen_reopen
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
assert_ruby_status([], "#{<<~"begin;"}\n#{<<~'end;'}")
begin;
io = File.open(IO::NULL)
io2 = io.dup
Expand Down Expand Up @@ -2387,7 +2387,7 @@ def test_clock_getres_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC
end

def test_deadlock_by_signal_at_forking
assert_separately(%W(- #{RUBY}), <<-INPUT, timeout: 100)
assert_ruby_status(%W(- #{RUBY}), <<-INPUT, timeout: 100)
ruby = ARGV.shift
GC.start # reduce garbage
GC.disable # avoid triggering CoW after forks
Expand Down
4 changes: 2 additions & 2 deletions test/ruby/test_require.rb
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ def test_require_with_loaded_features_pop
}

# [Bug #21567]
assert_separately(%w[-rtempfile], "#{<<~"begin;"}\n#{<<~"end;"}")
assert_ruby_status(%w[-rtempfile], "#{<<~"begin;"}\n#{<<~"end;"}")
begin;
class MyString
def initialize(path)
Expand Down Expand Up @@ -1029,7 +1029,7 @@ def test_resolve_feature_path_with_missing_feature

def test_require_with_public_method_missing
# [Bug #19793]
assert_separately(["-W0", "-rtempfile"], __FILE__, __LINE__, <<~RUBY, timeout: 60)
assert_ruby_status(["-W0", "-rtempfile"], <<~RUBY, timeout: 60)
GC.stress = true

class Object
Expand Down
6 changes: 3 additions & 3 deletions test/ruby/test_shapes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class Hi; end
end

def test_run_out_of_shape_for_object
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
assert_ruby_status([], "#{<<~"begin;"}\n#{<<~'end;'}")
begin;
class A
def initialize
Expand Down Expand Up @@ -339,7 +339,7 @@ def test_evacuate_object_ivar_and_compaction
end

def test_gc_stress_during_evacuate_generic_ivar
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
assert_ruby_status([], "#{<<~"begin;"}\n#{<<~'end;'}")
begin;
[].instance_variable_set(:@a, 1)

Expand Down Expand Up @@ -507,7 +507,7 @@ def initialize
end

def test_run_out_of_shape_rb_obj_copy_ivar
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
assert_ruby_status([], "#{<<~"begin;"}\n#{<<~'end;'}")
begin;
class A
def initialize
Expand Down
2 changes: 1 addition & 1 deletion test/ruby/test_signal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def test_self_stop

def test_sigwait_fd_unused
t = EnvUtil.apply_timeout_scale(0.1)
assert_separately([], <<-End)
assert_ruby_status([], <<-End)
tgt = $$
trap(:TERM) { exit(0) }
e = "Process.daemon; sleep #{t * 2}; Process.kill(:TERM,\#{tgt})"
Expand Down
4 changes: 2 additions & 2 deletions test/ruby/test_syntax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2296,13 +2296,13 @@ def test_argument_forwarding_with_super_memory_leak
end

def test_class_module_Object_ancestors
assert_separately([], <<-RUBY)
assert_ruby_status([], <<-RUBY)
m = Module.new
m::Bug18832 = 1
include m
class Bug18832; end
RUBY
assert_separately([], <<-RUBY)
assert_ruby_status([], <<-RUBY)
m = Module.new
m::Bug18832 = 1
include m
Expand Down
7 changes: 4 additions & 3 deletions test/ruby/test_thread.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,8 @@ def frame_for_deadlock_test_2

# [Bug #21342]
def test_unlock_locked_mutex_with_collected_fiber
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
bug21127 = '[ruby-core:120930] [Bug #21127]'
assert_ruby_status([], "#{<<~"begin;"}\n#{<<~'end;'}")
begin;
5.times do
m = Mutex.new
Expand All @@ -1611,7 +1612,7 @@ def test_unlock_locked_mutex_with_collected_fiber
end

def test_unlock_locked_mutex_with_collected_fiber2
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
assert_ruby_status([], "#{<<~"begin;"}\n#{<<~'end;'}")
begin;
MUTEXES = []
5.times do
Expand All @@ -1630,7 +1631,7 @@ def test_unlock_locked_mutex_with_collected_fiber2
end

def test_mutexes_locked_in_fiber_dont_have_aba_issue_with_new_fibers
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
assert_ruby_status([], "#{<<~"begin;"}\n#{<<~'end;'}")
begin;
mutexes = 1000.times.map do
Mutex.new
Expand Down
4 changes: 2 additions & 2 deletions test/ruby/test_weakmap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def test_compaction
@wm[i] = obj
end

assert_separately([], <<-'end;')
assert_ruby_status([], <<-'end;')
wm = ObjectSpace::WeakMap.new
obj = Object.new
100.times do
Expand All @@ -224,7 +224,7 @@ def test_compaction
assert_equal(val, wm[key])
end;

assert_separately(["-W0"], <<-'end;')
assert_ruby_status(["-W0"], <<-'end;')
wm = ObjectSpace::WeakMap.new

ary = 10_000.times.map do
Expand Down
2 changes: 1 addition & 1 deletion test/ruby/test_yield.rb
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def m.method_missing(*a)

def test_block_cached_argc
# [Bug #11451]
assert_separately([], <<-"end;")
assert_ruby_status([], <<-"end;")
class Yielder
def each
yield :x, :y, :z
Expand Down
2 changes: 1 addition & 1 deletion test/ruby/test_yjit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def compiled_counts = RubyVM::YJIT.runtime_stats&.dig(:compiled_iseq_count)
end

def test_yjit_enable_with_monkey_patch
assert_separately(%w[--yjit-disable], <<~RUBY)
assert_ruby_status(%w[--yjit-disable], <<~RUBY)
# This lets rb_method_entry_at(rb_mKernel, ...) return NULL
Kernel.prepend(Module.new)

Expand Down
Loading