Skip to content
Merged
2 changes: 1 addition & 1 deletion bootstraptest/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def main
if defined?(RUBY_DESCRIPTION)
puts "Driver is #{RUBY_DESCRIPTION}"
elsif defined?(RUBY_PATCHLEVEL)
puts "Driver is ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}#{RUBY_PLATFORM}) [#{RUBY_PLATFORM}]"
puts "Driver is ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}#{RUBY_PATCHLEVEL}) [#{RUBY_PLATFORM}]"
else
puts "Driver is ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
end
Expand Down
2 changes: 1 addition & 1 deletion class.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ rb_class_classext_free_subclasses(rb_classext_t *ext, VALUE klass, bool replacin
}
VM_ASSERT(
rb_box_subclasses_ref_count(anchor->box_subclasses) > 0,
"box_subclasses refcount (%p) %d", anchor->box_subclasses, rb_box_subclasses_ref_count(anchor->box_subclasses));
"box_subclasses refcount (%p) %ld", anchor->box_subclasses, rb_box_subclasses_ref_count(anchor->box_subclasses));
st_delete(tbl, &box_id, NULL);
rb_box_subclasses_ref_dec(anchor->box_subclasses);
xfree(anchor);
Expand Down
12 changes: 6 additions & 6 deletions internal/class.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,29 @@
#endif

struct rb_box_subclasses {
rb_atomic_t refcount;
long refcount;
struct st_table *tbl;
};
typedef struct rb_box_subclasses rb_box_subclasses_t;

static inline rb_atomic_t
static inline long
rb_box_subclasses_ref_count(rb_box_subclasses_t *box_sub)
{
return ATOMIC_LOAD_RELAXED(box_sub->refcount);
return box_sub->refcount;
}

static inline rb_box_subclasses_t *
rb_box_subclasses_ref_inc(rb_box_subclasses_t *box_sub)
{
RUBY_ATOMIC_FETCH_ADD(box_sub->refcount, 1);
box_sub->refcount++;
return box_sub;
}

static inline void
rb_box_subclasses_ref_dec(rb_box_subclasses_t *box_sub)
{
rb_atomic_t was = RUBY_ATOMIC_FETCH_SUB(box_sub->refcount, 1);
if (was == 1) {
box_sub->refcount--;
if (box_sub->refcount == 0) {
st_free_table(box_sub->tbl);
xfree(box_sub);
}
Expand Down
4 changes: 2 additions & 2 deletions spec/bundler/quality_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ def check_for_specific_pronouns(filename)
end

it "can still be built" do
with_built_bundler do |_gem_path|
expect(err).to be_empty, "bundler should build as a gem without warnings, but\n#{err}"
with_built_bundler do |gem_path|
expect(File.exist?(gem_path)).to be true
end
end

Expand Down
31 changes: 21 additions & 10 deletions spec/bundler/support/builders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

require "bundler/shared_helpers"
require "shellwords"
require "fileutils"
require "rubygems/package"

require_relative "build_metadata"

Expand Down Expand Up @@ -423,21 +425,29 @@ def required_ruby_version=(*reqs)
end

class BundlerBuilder
attr_writer :required_ruby_version
SPEC = Gem::Specification.load(Spec::Path.relative_gemspec)

def initialize(context, name, version)
raise "can only build bundler" unless name == "bundler"

@context = context
@version = version || Bundler::VERSION
@spec = SPEC.dup
@spec.version = version || Bundler::VERSION
end

def required_ruby_version
@spec.required_ruby_version
end

def required_ruby_version=(x)
@spec.required_ruby_version = x
end

def _build(options = {})
full_name = "bundler-#{@version}"
full_name = "bundler-#{@spec.version}"
build_path = (options[:build_path] || @context.tmp) + full_name
bundler_path = build_path + "#{full_name}.gem"

require "fileutils"
FileUtils.mkdir_p build_path

@context.shipped_files.each do |shipped_file|
Expand All @@ -449,13 +459,14 @@ def _build(options = {})
FileUtils.cp File.expand_path(shipped_file, @context.source_root), target_shipped_file, preserve: true
end

@context.replace_version_file(@version, dir: build_path)
@context.replace_changelog(@version, dir: build_path) if options[:released]
@context.replace_required_ruby_version(@required_ruby_version, dir: build_path) if @required_ruby_version
@context.replace_version_file(@spec.version, dir: build_path)
@context.replace_changelog(@spec.version, dir: build_path) if options[:released]

Spec::BuildMetadata.write_build_metadata(dir: build_path, version: @version)
Spec::BuildMetadata.write_build_metadata(dir: build_path, version: @spec.version.to_s)

@context.gem_command "build #{@context.relative_gemspec}", dir: build_path
Dir.chdir build_path do
Gem::Package.build(@spec)
end

if block_given?
yield(bundler_path)
Expand Down Expand Up @@ -659,7 +670,7 @@ def _build(opts)
elsif opts[:skip_validation]
@context.gem_command "build --force #{@spec.name}", dir: lib_path
else
@context.gem_command "build #{@spec.name}", dir: lib_path, allowed_warning: opts[:allowed_warning]
Dir.chdir(lib_path) { Gem::Package.build(@spec) }
end

gem_path = File.expand_path("#{@spec.full_name}.gem", lib_path)
Expand Down
15 changes: 0 additions & 15 deletions test/ruby/test_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -887,19 +887,4 @@ def test_method_table_assignment_just_after_class_init
class C; end
end;
end

def test_subclasses_refcount_in_ractors
assert_ractor "#{<<~"begin;"}\n#{<<~'end;'}"
begin;
rs = []
8.times do
rs << Ractor.new do
5_000.times do
Class.new
end
end
end
rs.each(&:join)
end;
end
end
12 changes: 12 additions & 0 deletions test/ruby/test_refinement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2724,6 +2724,18 @@ def test_refined_module_method
assert_equal :qux, meth.name
end

def test_symbol_proc_from_using_scope
# assert_separately to contain the side effects of refining Kernel
assert_separately([], <<~RUBY)
class RefinedScope
using(Module.new { refine(Kernel) { def itself = 0 } })
ITSELF = :itself.to_proc
end

assert_equal(1, RefinedScope::ITSELF[1], "[Bug #21265]")
RUBY
end

private

def eval_using(mod, s)
Expand Down
2 changes: 0 additions & 2 deletions test/ruby/test_zjit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3165,8 +3165,6 @@ def test(define)
end

def test_regression_cfp_sp_set_correctly_before_leaf_gc_call
omit 'reproduction for known, unresolved ZJIT bug'

assert_compiles ':ok', %q{
def check(l, r)
return 1 unless l
Expand Down
5 changes: 4 additions & 1 deletion thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -2935,7 +2935,10 @@ thread_raise_m(int argc, VALUE *argv, VALUE self)
*
* Terminates +thr+ and schedules another thread to be run, returning
* the terminated Thread. If this is the main thread, or the last
* thread, exits the process.
* thread, exits the process. Note that the caller does not wait for
* the thread to terminate if the receiver is different from the currently
* running thread. The termination is asynchronous, and the thread can still
* run a small amount of ruby code before exiting.
*/

VALUE
Expand Down
32 changes: 18 additions & 14 deletions thread_pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -2592,16 +2592,14 @@ ubf_threads_empty(void)
static void
ubf_wakeup_all_threads(void)
{
if (!ubf_threads_empty()) {
rb_thread_t *th;
rb_native_mutex_lock(&ubf_list_lock);
{
ccan_list_for_each(&ubf_list_head, th, sched.node.ubf) {
ubf_wakeup_thread(th);
}
rb_thread_t *th;
rb_native_mutex_lock(&ubf_list_lock);
{
ccan_list_for_each(&ubf_list_head, th, sched.node.ubf) {
ubf_wakeup_thread(th);
}
rb_native_mutex_unlock(&ubf_list_lock);
}
rb_native_mutex_unlock(&ubf_list_lock);
}

#else /* USE_UBF_LIST */
Expand Down Expand Up @@ -2995,6 +2993,17 @@ timer_thread_deq_wakeup(rb_vm_t *vm, rb_hrtime_t now)
return NULL;
}

static void
timer_thread_wakeup_thread_locked(struct rb_thread_sched *sched, rb_thread_t *th)
{
if (sched->running != th) {
thread_sched_to_ready_common(sched, th, true, false);
}
else {
// will be release the execution right
}
}

static void
timer_thread_wakeup_thread(rb_thread_t *th)
{
Expand All @@ -3003,12 +3012,7 @@ timer_thread_wakeup_thread(rb_thread_t *th)

thread_sched_lock(sched, th);
{
if (sched->running != th) {
thread_sched_to_ready_common(sched, th, true, false);
}
else {
// will be release the execution right
}
timer_thread_wakeup_thread_locked(sched, th);
}
thread_sched_unlock(sched, th);
}
Expand Down
Loading