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: 0 additions & 5 deletions bignum.c
Original file line number Diff line number Diff line change
Expand Up @@ -6371,11 +6371,6 @@ rb_big_fdiv_double(VALUE x, VALUE y)
return NUM2DBL(v);
}

VALUE
rb_big_fdiv(VALUE x, VALUE y)
{
return DBL2NUM(rb_big_fdiv_double(x, y));
}

VALUE
rb_big_pow(VALUE x, VALUE y)
Expand Down
11 changes: 11 additions & 0 deletions bootstraptest/test_gc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,14 @@
end
end
}, '[ruby-dev:39453]'

assert_normal_exit %q{
# A class whose instances start with a complex shape: as.extended must be
# initialized before the fields object allocation can trigger a GC.
ivars = 1024.times.map { |i| "@iv_#{i} = #{i}\n" }.join
klass = Class.new
klass.class_eval "def initialize() #{ivars} end"
GC.stress = true
klass.allocate
GC.stress = false
}, 'complex T_OBJECT marked before as.extended is set'
3 changes: 3 additions & 0 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,9 @@ static
VALUE class_allocate_complex_instance(VALUE klass, uint32_t capacity)
{
VALUE obj = rb_newobj_of_with_shape(klass, T_OBJECT, rb_shape_transition_extended(ROOT_COMPLEX_SHAPE_ID), sizeof(struct RObject));
// The shape already says extended, so a GC during the allocation below
// would mark an uninitialized as.extended.
ROBJECT(obj)->as.extended = Qfalse;
VALUE fields_obj = rb_imemo_fields_new_complex(obj, ROOT_COMPLEX_SHAPE_ID, capacity, false);
ROBJECT_SET_EXTENDED(obj, fields_obj);
return obj;
Expand Down
5 changes: 0 additions & 5 deletions io.c
Original file line number Diff line number Diff line change
Expand Up @@ -7428,11 +7428,6 @@ rb_io_synchronized(rb_io_t *fptr)
fptr->mode |= FMODE_SYNC;
}

void
rb_io_unbuffered(rb_io_t *fptr)
{
rb_io_synchronized(fptr);
}

int
rb_pipe(int *pipes)
Expand Down
48 changes: 39 additions & 9 deletions lib/resolv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -880,20 +880,37 @@ def lazy_initialize
@mutex.synchronize {
next if @initialized
@initialized = true
is_ipv6 = @host.index(':')
sock = UDPSocket.new(is_ipv6 ? Socket::AF_INET6 : Socket::AF_INET)
@socks = [sock]
sock.do_not_reverse_lookup = true
DNS.bind_random_port(sock, is_ipv6 ? "::" : "0.0.0.0")
sock.connect(@host, @port)
connect_socket
}
self
end

# The socket to talk to the nameserver over, opening one if there is
# none yet. #recv_reply may have replaced it since a sender was
# created, so senders ask for it per request instead of holding on to
# one.
def sock
lazy_initialize
@socks[0]
end

def recv_reply(readable_socks, timelimit = nil)
lazy_initialize
reply = readable_socks[0].recv(UDPSize)
return reply, nil
rescue Errno::ECONNREFUSED, Errno::ECONNRESET
# The kernel reports these from an ICMP message, and a second one for
# the same pair of endpoints is not always passed on: macOS 26.1 and
# later deliver every other one. A retry over this socket would then
# wait out its whole timeout rather than fail at once, so start over
# from a new source port.
@mutex.synchronize {
if @initialized
@socks&.each(&:close)
connect_socket
end
}
raise
end

def sender(msg, data, host=@host, port=@port)
Expand All @@ -904,7 +921,7 @@ def sender(msg, data, host=@host, port=@port)
id = DNS.allocate_request_id(@host, @port)
request = msg.encode
request[0,2] = [id].pack('n')
return @senders[[nil,id]] = Sender.new(request, data, @socks[0])
return @senders[[nil,id]] = Sender.new(request, data, self)
end

def close
Expand All @@ -919,10 +936,23 @@ def close
end
end

private def connect_socket
is_ipv6 = @host.index(':')
sock = UDPSocket.new(is_ipv6 ? Socket::AF_INET6 : Socket::AF_INET)
@socks = [sock]
sock.do_not_reverse_lookup = true
DNS.bind_random_port(sock, is_ipv6 ? "::" : "0.0.0.0")
sock.connect(@host, @port)
end

class Sender < Requester::Sender # :nodoc:
def initialize(msg, data, requester)
super(msg, data, nil)
@requester = requester
end

def send
raise "@sock is nil." if @sock.nil?
@sock.send(@msg, 0)
@requester.sock.send(@msg, 0)
end
attr_reader :data
end
Expand Down
5 changes: 0 additions & 5 deletions ractor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1452,11 +1452,6 @@ rb_ractor_stderr_set(VALUE err)
}
}

rb_hook_list_t *
rb_ractor_hooks(rb_ractor_t *cr)
{
return &cr->pub.hooks;
}

st_table *
rb_ractor_targeted_hooks(rb_ractor_t *cr)
Expand Down
2 changes: 1 addition & 1 deletion spec/syntax_suggest/integration/ruby_command_line_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def lol
puts "haha"
EOM

out = `SYNTAX_SUGGEST_DEBUG=1 #{ruby} -I#{lib_dir} -rsyntax_suggest -r#{monkeypatch} #{script} 2>&1`
out = IO.popen({"SYNTAX_SUGGEST_DEBUG" => "1"}, "#{ruby} -I#{lib_dir} -rsyntax_suggest -r#{monkeypatch} #{script} 2>&1", &:read)

expect($?.success?).to be_falsey
expect(out).to include("boom from monkeypatch")
Expand Down
4 changes: 2 additions & 2 deletions test/-ext-/bug_reporter/test_bug_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

class TestBugReporter < Test::Unit::TestCase
def test_bug_reporter_add
omit if macos? && ENV["CI"] # we're getting timeouts even after 100s in CI
description = RUBY_DESCRIPTION
description = description.sub(/\+PRISM /, '') unless ParserSupport.prism_enabled_in_subprocess?
expected_stderr = [
Expand All @@ -26,7 +25,8 @@ def test_bug_reporter_add
args.push("--zjit") if JITSupport.zjit_enabled?
args.unshift({"RUBY_ON_BUG" => nil, "RUBY_CRASH_REPORT" => nil})
stdin = "#{no_core}register_sample_bug_reporter(12345); Bug.segv"
assert_in_out_err(args, stdin, [], expected_stderr, encoding: "ASCII-8BIT")
# Writing the report is slow, see TestRubyOptions#assert_segv.
assert_in_out_err(args, stdin, [], expected_stderr, encoding: "ASCII-8BIT", timeout: 60)
ensure
FileUtils.rm_rf(tmpdir) if tmpdir
end
Expand Down
2 changes: 0 additions & 2 deletions test/resolv/test_dns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,6 @@ def test_no_server
if RUBY_PLATFORM.match?(/mingw/)
# cannot repo locally
omit 'Timeout Error on MinGW CI'
elsif macos?([26,1]..[])
omit 'Timeout Error on macOS 26.1+'
else
raise Timeout::Error
end
Expand Down
1 change: 0 additions & 1 deletion test/ruby/test_array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1821,7 +1821,6 @@ def test_slice_out_of_range
end

def test_slice_gc_compact_stress
omit "compaction doesn't work well on s390x" if RUBY_PLATFORM =~ /s390x/ # https://github.com/ruby/ruby/pull/5077
EnvUtil.under_gc_compact_stress { assert_equal([1, 2, 3, 4, 5], (0..10).to_a[1, 5]) }
EnvUtil.under_gc_compact_stress do
a = [0, 1, 2, 3, 4, 5]
Expand Down
2 changes: 0 additions & 2 deletions test/ruby/test_enumerator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ def test_with_index
end

def test_with_index_under_gc_compact_stress
omit "compaction doesn't work well on s390x" if RUBY_PLATFORM =~ /s390x/ # https://github.com/ruby/ruby/pull/5077
EnvUtil.under_gc_compact_stress do
assert_equal([[1, 0], [2, 1], [3, 2]], @obj.to_enum(:foo, 1, 2, 3).with_index.to_a)
assert_equal([[1, 5], [2, 6], [3, 7]], @obj.to_enum(:foo, 1, 2, 3).with_index(5).to_a)
Expand Down Expand Up @@ -864,7 +863,6 @@ def test_lazy_chain
end

def test_lazy_chain_under_gc_compact_stress
omit "compaction doesn't work well on s390x" if RUBY_PLATFORM =~ /s390x/ # https://github.com/ruby/ruby/pull/5077
EnvUtil.under_gc_compact_stress do
ea = (10..).lazy.select(&:even?).take(10)
ed = (20..).lazy.select(&:odd?)
Expand Down
1 change: 0 additions & 1 deletion test/ruby/test_eval.rb
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,6 @@ def test_syntax_error_no_memory_leak

def test_outer_local_variable_under_gc_compact_stress
omit "compaction is not supported on this platform" unless GC.respond_to?(:compact)
omit "compaction is not supported on s390x" if /s390x/ =~ RUBY_PLATFORM

assert_separately([], <<~RUBY)
o = Object.new
Expand Down
2 changes: 0 additions & 2 deletions test/ruby/test_exception.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1478,8 +1478,6 @@ def test_detailed_message
end

def test_detailed_message_under_gc_compact_stress
omit "compaction doesn't work well on s390x" if RUBY_PLATFORM =~ /s390x/ # https://github.com/ruby/ruby/pull/5077

# The first error display lazily requires did_you_mean and friends; inside the
# block that library load costs one full mark+compact per allocation, enough to
# trip the parallel runner's no-response timeout. Load it here instead.
Expand Down
5 changes: 0 additions & 5 deletions test/ruby/test_gc_compact.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# frozen_string_literal: true
require 'test/unit'

if RUBY_PLATFORM =~ /s390x/
warn "Currently, it is known that the compaction does not work well on s390x; contribution is welcome https://github.com/ruby/ruby/pull/5077"
return
end

class TestGCCompact < Test::Unit::TestCase
module CompactionSupportInspector
def supports_compact?
Expand Down
1 change: 0 additions & 1 deletion test/ruby/test_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,6 @@ def m.bar; :bar; end
end

def test_clone_under_gc_compact_stress
omit "compaction doesn't work well on s390x" if RUBY_PLATFORM =~ /s390x/ # https://github.com/ruby/ruby/pull/5077
EnvUtil.under_gc_compact_stress do
o = Object.new
def o.foo; :foo; end
Expand Down
2 changes: 1 addition & 1 deletion test/ruby/test_ractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def test_require_non_string

# [Bug #21398]
def test_port_receive_dnt_with_port_send
omit 'unstable on windows and macos-14' if RUBY_PLATFORM =~ /mswin|mingw|darwin/
omit 'unstable on windows' if RUBY_PLATFORM =~ /mswin|mingw/
assert_ractor(<<~'RUBY', timeout: 90)
THREADS = 10
JOBS_PER_THREAD = 50
Expand Down
4 changes: 0 additions & 4 deletions test/ruby/test_regexp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def test_to_s
end

def test_to_s_under_gc_compact_stress
omit "compaction doesn't work well on s390x" if RUBY_PLATFORM =~ /s390x/ # https://github.com/ruby/ruby/pull/5077
EnvUtil.under_gc_compact_stress do
str = "abcd\u3042"
[:UTF_16BE, :UTF_16LE, :UTF_32BE, :UTF_32LE].each do |es|
Expand Down Expand Up @@ -471,7 +470,6 @@ def test_inspect
end

def test_inspect_under_gc_compact_stress
omit "compaction doesn't work well on s390x" if RUBY_PLATFORM =~ /s390x/ # https://github.com/ruby/ruby/pull/5077
EnvUtil.under_gc_compact_stress do
assert_equal('/(?-mix:\\/)|/', Regexp.union(/\//, "").inspect)
end
Expand Down Expand Up @@ -904,7 +902,6 @@ def test_match
end

def test_match_under_gc_compact_stress
omit "compaction doesn't work well on s390x" if RUBY_PLATFORM =~ /s390x/ # https://github.com/ruby/ruby/pull/5077
EnvUtil.under_gc_compact_stress do
m = /(?<foo>.)(?<n>[^aeiou])?(?<bar>.+)/.match("hoge\u3042")
assert_equal("h", m.match(:foo))
Expand Down Expand Up @@ -2142,7 +2139,6 @@ def test_timeout_shorter_than_global
end

def test_timeout_longer_than_global
omit "timeout test is too unstable on s390x" if RUBY_PLATFORM =~ /s390x/
per_instance_redos_test(0.01, 0.5, 0.5)
end

Expand Down
10 changes: 7 additions & 3 deletions test/ruby/test_rubyoptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,12 @@ module SEGVTest
KILL_SELF = "Bug.segv"
end

def assert_segv(args, message=nil, list: SEGVTest::ExpectedStderrList, **opt, &block)
omit if macos? && ENV["CI"] # we're getting timeouts even after 100s in CI, not sure why.
# Turning the C level backtrace into file:line pairs walks the whole of the
# binary's debug info, and that is nearly all of what a crash costs: 0.8s of
# CPU with the dSYM in place against 0.01s without it, on an idle arm64 macOS
# host. The default subprocess budget of 10 seconds is meant for a child
# that does none of that work.
def assert_segv(args, message=nil, list: SEGVTest::ExpectedStderrList, timeout: 60, **opt, &block)
# We want YJIT to be enabled in the subprocess if it's enabled for us
# so that the Ruby description matches.
env = Hash === args.first ? args.shift : {}
Expand All @@ -867,7 +871,7 @@ def assert_segv(args, message=nil, list: SEGVTest::ExpectedStderrList, **opt, &b
end

assert_in_out_err(args, test_stdin, *tests, encoding: "ASCII-8BIT",
**SEGVTest::ExecOptions, **opt, &block)
timeout: timeout, **SEGVTest::ExecOptions, **opt, &block)
end

def test_segv_test
Expand Down
5 changes: 0 additions & 5 deletions test/ruby/test_string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,6 @@ def test_undump
end

def test_undump_gc_compact_stress
omit "compaction doesn't work well on s390x" if RUBY_PLATFORM =~ /s390x/ # https://github.com/ruby/ruby/pull/5077
a = S("Test") << 1 << 2 << 3 << 9 << 13 << 10
EnvUtil.under_gc_compact_stress do
assert_equal(a, S('"Test\\x01\\x02\\x03\\t\\r\\n"').undump)
Expand Down Expand Up @@ -1451,7 +1450,6 @@ def test_gsub
end

def test_gsub_gc_compact_stress
omit "compaction doesn't work well on s390x" if RUBY_PLATFORM =~ /s390x/ # https://github.com/ruby/ruby/pull/5077
EnvUtil.under_gc_compact_stress { assert_equal(S("h<e>ll<o>"), S("hello").gsub(/([aeiou])/, S('<\1>'))) }
end

Expand Down Expand Up @@ -1499,7 +1497,6 @@ def test_gsub!
end

def test_gsub_bang_gc_compact_stress
omit "compaction doesn't work well on s390x" if RUBY_PLATFORM =~ /s390x/ # https://github.com/ruby/ruby/pull/5077
EnvUtil.under_gc_compact_stress do
a = S("hello")
a.gsub!(/([aeiou])/, S('<\1>'))
Expand Down Expand Up @@ -1870,7 +1867,6 @@ def test_scan
end

def test_scan_gc_compact_stress
omit "compaction doesn't work well on s390x" if RUBY_PLATFORM =~ /s390x/ # https://github.com/ruby/ruby/pull/5077
EnvUtil.under_gc_compact_stress { assert_equal([["1a"], ["2b"], ["3c"]], S("1a2b3c").scan(/(\d.)/)) }
end

Expand Down Expand Up @@ -2418,7 +2414,6 @@ def o.to_s; self; end
end

def test_sub_gc_compact_stress
omit "compaction doesn't work well on s390x" if RUBY_PLATFORM =~ /s390x/ # https://github.com/ruby/ruby/pull/5077
EnvUtil.under_gc_compact_stress do
m = /&(?<foo>.*?);/.match(S("aaa &amp; yyy"))
assert_equal("amp", m["foo"])
Expand Down
2 changes: 0 additions & 2 deletions test/ruby/test_symbol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ def test_inspect
end

def test_inspect_under_gc_compact_stress
omit "compaction doesn't work well on s390x" if RUBY_PLATFORM =~ /s390x/ # https://github.com/ruby/ruby/pull/5077

EnvUtil.under_gc_compact_stress do
assert_inspect_evaled(':testing')
end
Expand Down
1 change: 0 additions & 1 deletion test/ruby/test_transcode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2398,7 +2398,6 @@ def test_ractor_lazy_load_encoding
end

def test_ractor_lazy_load_encoding_random
omit 'unstable on s390x' if RUBY_PLATFORM =~ /s390x/
assert_ractor("#{<<~"begin;"}\n#{<<~'end;'}", timeout: 30)
begin;
rs = []
Expand Down
1 change: 0 additions & 1 deletion test/ruby/test_variable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,6 @@ def test_external_ivars
end

def test_exivar_resize_with_compaction_stress
omit "compaction doesn't work well on s390x" if RUBY_PLATFORM =~ /s390x/ # https://github.com/ruby/ruby/pull/5077
objs = 10_000.times.map do
ExIvar.new
end
Expand Down
1 change: 0 additions & 1 deletion test/ruby/test_weakkeymap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ def test_compaction
end

def test_gc_compact_stress
omit "compaction doesn't work well on s390x" if RUBY_PLATFORM =~ /s390x/ # https://github.com/ruby/ruby/pull/5077
EnvUtil.under_gc_compact_stress { ObjectSpace::WeakKeyMap.new }
end

Expand Down
1 change: 0 additions & 1 deletion test/ruby/test_weakmap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ def test_compaction
end

def test_gc_compact_stress
omit "compaction doesn't work well on s390x" if RUBY_PLATFORM =~ /s390x/ # https://github.com/ruby/ruby/pull/5077
EnvUtil.under_gc_compact_stress { ObjectSpace::WeakMap.new }
end

Expand Down
3 changes: 1 addition & 2 deletions thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -2861,7 +2861,7 @@ rb_threadptr_execute_interrupts(rb_thread_t *th, int blocking_timing)
}

if (postponed_job_interrupt) {
rb_postponed_job_flush(th->vm);
rb_postponed_job_flush();
}

if (trap_interrupt) {
Expand Down Expand Up @@ -5947,7 +5947,6 @@ Init_Thread_Mutex(void)
{
rb_thread_t *th = GET_THREAD();

rb_native_mutex_initialize(&th->vm->workqueue_lock);
rb_native_mutex_initialize(&th->vm->once_lock);
rb_native_cond_initialize(&th->vm->once_cond);
rb_native_mutex_initialize(&th->interrupt_lock);
Expand Down
Loading