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
12 changes: 12 additions & 0 deletions .github/actions/launchable/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ inputs:
description: >-
Whether this workflow is executed on YJIT.

is-zjit:
required: false
default: 'false'
description: >-
Whether this workflow is executed on ZJIT.

outputs:
stdout_report_path:
value: ${{ steps.global.outputs.stdout_report_path }}
Expand Down Expand Up @@ -204,6 +210,11 @@ runs:
btest_test_suite="yjit-${btest_test_suite}"
test_spec_test_suite="yjit-${test_spec_test_suite}"
fi
if [ "${INPUT_IS_ZJIT}" = "true" ]; then
test_all_test_suite="zjit-${test_all_test_suite}"
btest_test_suite="zjit-${btest_test_suite}"
test_spec_test_suite="zjit-${test_spec_test_suite}"
fi
# launchable_setup target var -- refers ${target} prefixed variables
launchable_setup() {
local target=$1 session
Expand Down Expand Up @@ -239,6 +250,7 @@ runs:
INPUT_GITHUB_REF: ${{ github.ref }}
INPUT_TEST_OPTS: ${{ inputs.test-opts }}
INPUT_IS_YJIT: ${{ inputs.is-yjit }}
INPUT_IS_ZJIT: ${{ inputs.is-zjit }}
INPUT_OS: ${{ inputs.os }}
INPUT_TEST_TASK: ${{ inputs.test-task }}
INPUT_WORKFLOW: ${{ github.workflow }}
Expand Down
20 changes: 19 additions & 1 deletion .github/workflows/zjit-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,24 @@ jobs:
run: |
echo "RUBY_CRASH_REPORT=$(pwd)/rb_crash_%p.txt" >> $GITHUB_ENV

- name: Set up Launchable
id: launchable
uses: ./.github/actions/launchable/setup
with:
os: macos-14
test-opts: ${{ matrix.configure }}
launchable-token: ${{ secrets.LAUNCHABLE_TOKEN }}
builddir: build
srcdir: src
is-zjit: true
continue-on-error: true
timeout-minutes: 3

- name: make ${{ matrix.test_task }}
run: |
test -n "${LAUNCHABLE_STDOUT}" && exec 1> >(tee "${LAUNCHABLE_STDOUT}")
test -n "${LAUNCHABLE_STDERR}" && exec 2> >(tee "${LAUNCHABLE_STDERR}")

set -x
make -s ${{ matrix.test_task }} ${TESTS:+TESTS="$TESTS"} \
RUN_OPTS="$RUN_OPTS" \
Expand All @@ -125,8 +141,10 @@ jobs:
RUBY_TESTOPTS: '-q --tty=no'
EXCLUDES: '../src/test/.excludes-zjit'
TEST_BUNDLED_GEMS_ALLOW_FAILURES: ''
SYNTAX_SUGGEST_TIMEOUT: '5'
SYNTAX_SUGGEST_TIMEOUT: '30'
PRECHECK_BUNDLED_GEMS: 'no'
LAUNCHABLE_STDOUT: ${{ steps.launchable.outputs.stdout_report_path }}
LAUNCHABLE_STDERR: ${{ steps.launchable.outputs.stderr_report_path }}
continue-on-error: ${{ matrix.continue-on-test_task || false }}

- name: Dump crash logs
Expand Down
20 changes: 19 additions & 1 deletion .github/workflows/zjit-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,24 @@ jobs:
run: |
echo "RUBY_CRASH_REPORT=$(pwd)/rb_crash_%p.txt" >> $GITHUB_ENV

- name: Set up Launchable
id: launchable
uses: ./.github/actions/launchable/setup
with:
os: ${{ matrix.runs-on || 'ubuntu-22.04' }}
test-opts: ${{ matrix.configure }}
launchable-token: ${{ secrets.LAUNCHABLE_TOKEN }}
builddir: build
srcdir: src
is-zjit: true
continue-on-error: true
timeout-minutes: 3

- name: make ${{ matrix.test_task }}
run: |
test -n "${LAUNCHABLE_STDOUT}" && exec 1> >(tee "${LAUNCHABLE_STDOUT}")
test -n "${LAUNCHABLE_STDERR}" && exec 2> >(tee "${LAUNCHABLE_STDERR}")

set -x
make -s ${{ matrix.test_task }} ${TESTS:+TESTS="$TESTS"} \
RUN_OPTS="$RUN_OPTS" MSPECOPT=--debug SPECOPTS="$SPECOPTS" \
Expand All @@ -182,9 +198,11 @@ jobs:
EXCLUDES: '../src/test/.excludes-zjit'
TEST_BUNDLED_GEMS_ALLOW_FAILURES: ''
PRECHECK_BUNDLED_GEMS: 'no'
SYNTAX_SUGGEST_TIMEOUT: '5'
SYNTAX_SUGGEST_TIMEOUT: '30'
ZJIT_BINDGEN_DIFF_OPTS: '--exit-code'
CLANG_PATH: ${{ matrix.clang_path }}
LAUNCHABLE_STDOUT: ${{ steps.launchable.outputs.stdout_report_path }}
LAUNCHABLE_STDERR: ${{ steps.launchable.outputs.stderr_report_path }}
continue-on-error: ${{ matrix.continue-on-test_task || false }}

- name: Dump crash logs
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ releases.

* RubyGems 4.1.0.dev
* bundler 4.1.0.dev
* json 2.19.1
* json 2.19.2
* 2.18.0 to [v2.18.1][json-v2.18.1], [v2.19.0][json-v2.19.0], [v2.19.1][json-v2.19.1]
* openssl 4.0.1
* 4.0.0 to [v4.0.1][openssl-v4.0.1]
Expand Down
97 changes: 93 additions & 4 deletions bootstraptest/test_ractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1021,8 +1021,8 @@ def initialize
values.join
}

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

# 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 (@@cv from C)', %q{
# also cached non-shareable cvar read from non-main Ractor is not allowed
assert_equal 'can not read non-shareable class variable @@cv from non-main Ractors (C)', %q{
class C
@@cv = 'str'
def self.cv
Expand All @@ -1062,6 +1062,95 @@ def self.cv
end
}

# Reading shareable cvar from non-main Ractor is allowed
assert_equal 'shareable', %q{
class C
@@cv = 'shareable'.freeze
def self.cv
@@cv
end
end

Ractor.new { C.cv }.value
}

# Reading shareable cvar (integer) from non-main Ractor is allowed
assert_equal '42', %q{
class C
@@cv = 42
def self.cv
@@cv
end
end

Ractor.new { C.cv }.value.to_s
}

# Reading shareable cvar via module include from non-main Ractor is allowed
assert_equal 'hello', %q{
module M
@@cv = 'hello'.freeze
def self.cv
@@cv
end
end

class C
include M
def self.cv
@@cv
end
end

Ractor.new { C.cv }.value
}

# Writing cvar from non-main Ractor is not allowed
assert_equal 'can not set class variables from non-main Ractors (@@cv from C)', %q{
class C
@@cv = 'str'
def self.cv=(v)
@@cv = v
end
end

r = Ractor.new do
C.cv = 'new'
end

begin
r.join
rescue Ractor::RemoteError => e
e.cause.message
end
}

# Reading cvar that was made shareable after initial assignment
assert_equal 'made shareable', %q{
class C
@@cv = +'made shareable'
Ractor.make_shareable(@@cv)
def self.cv
@@cv
end
end

Ractor.new { C.cv }.value
}

# cvar_defined? works from non-main Ractor
assert_equal 'true', %q{
class C
@@cv = 42
def self.cv?
defined?(@@cv)
end
end

r = Ractor.new { C.cv? ? 'true' : 'false' }
r.value
}

# Getting non-shareable objects via constants by other Ractors is not allowed
assert_equal 'can not access non-shareable objects in constant C::CONST by non-main Ractor.', <<~'RUBY', frozen_string_literal: false
class C
Expand Down
2 changes: 1 addition & 1 deletion ext/json/lib/json/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module JSON
VERSION = '2.19.1'
VERSION = '2.19.2'
end
23 changes: 19 additions & 4 deletions ext/json/parser/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,9 @@ static void emit_parse_warning(const char *message, JSON_ParserState *state)

#define PARSE_ERROR_FRAGMENT_LEN 32

NORETURN(static) void raise_parse_error(const char *format, JSON_ParserState *state)
static VALUE build_parse_error_message(const char *format, JSON_ParserState *state, long line, long column)
{
unsigned char buffer[PARSE_ERROR_FRAGMENT_LEN + 3];
long line, column;
cursor_position(state, &line, &column);

const char *ptr = "EOF";
if (state->cursor && state->cursor < state->end) {
Expand Down Expand Up @@ -441,11 +439,23 @@ NORETURN(static) void raise_parse_error(const char *format, JSON_ParserState *st
VALUE msg = rb_sprintf(format, ptr);
VALUE message = rb_enc_sprintf(enc_utf8, "%s at line %ld column %ld", RSTRING_PTR(msg), line, column);
RB_GC_GUARD(msg);
return message;
}

static VALUE parse_error_new(VALUE message, long line, long column)
{
VALUE exc = rb_exc_new_str(rb_path2class("JSON::ParserError"), message);
rb_ivar_set(exc, rb_intern("@line"), LONG2NUM(line));
rb_ivar_set(exc, rb_intern("@column"), LONG2NUM(column));
rb_exc_raise(exc);
return exc;
}

NORETURN(static) void raise_parse_error(const char *format, JSON_ParserState *state)
{
long line, column;
cursor_position(state, &line, &column);
VALUE message = build_parse_error_message(format, state, line, column);
rb_exc_raise(parse_error_new(message, line, column));
}

NORETURN(static) void raise_parse_error_at(const char *format, JSON_ParserState *state, const char *at)
Expand Down Expand Up @@ -895,6 +905,11 @@ NORETURN(static) void raise_duplicate_key_error(JSON_ParserState *state, VALUE d
rb_inspect(duplicate_key)
);

long line, column;
cursor_position(state, &line, &column);
rb_str_concat(message, build_parse_error_message("", state, line, column)) ;
rb_exc_raise(parse_error_new(message, line, column));

raise_parse_error(RSTRING_PTR(message), state);
RB_GC_GUARD(message);
}
Expand Down
2 changes: 2 additions & 0 deletions lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,8 @@ def converge_sources
end
end

sources.metadata_source.checksum_store.merge!(@locked_gems.metadata_source.checksum_store) if @locked_gems

changes
end

Expand Down
15 changes: 14 additions & 1 deletion lib/bundler/lockfile_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def add_checksums
checksums = definition.resolve.map do |spec|
spec.source.checksum_store.to_lock(spec)
end
add_section("CHECKSUMS", checksums)

add_section("CHECKSUMS", checksums + bundler_checksum)
end

def add_locked_ruby_version
Expand Down Expand Up @@ -100,5 +101,17 @@ def add_section(name, value)
raise ArgumentError, "#{value.inspect} can't be serialized in a lockfile"
end
end

def bundler_checksum
return [] if Bundler.gem_version.to_s.end_with?(".dev")

require "rubygems/package"

bundler_spec = definition.sources.metadata_source.specs.search(["bundler", Bundler.gem_version]).last
package = Gem::Package.new(bundler_spec.cache_file)
definition.sources.metadata_source.checksum_store.register(bundler_spec, Checksum.from_gem_package(package))

[definition.sources.metadata_source.checksum_store.to_lock(bundler_spec)]
end
end
end
9 changes: 8 additions & 1 deletion lib/bundler/lockfile_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def to_s

attr_reader(
:sources,
:metadata_source,
:dependencies,
:specs,
:platforms,
Expand Down Expand Up @@ -97,6 +98,7 @@ def self.bundled_with
def initialize(lockfile, strict: false)
@platforms = []
@sources = []
@metadata_source = Source::Metadata.new
@dependencies = {}
@parse_method = nil
@specs = {}
Expand Down Expand Up @@ -252,7 +254,12 @@ def parse_checksum(line)
version = Gem::Version.new(version)
platform = platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY
full_name = Gem::NameTuple.new(name, version, platform).full_name
return unless spec = @specs[full_name]
spec = @specs[full_name]

if name == "bundler"
spec ||= LazySpecification.new(name, version, platform, @metadata_source)
end
return unless spec

if checksums
checksums.split(",") do |lock_checksum|
Expand Down
4 changes: 4 additions & 0 deletions lib/bundler/source/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ def hash
def version_message(spec)
"#{spec.name} #{spec.version}"
end

def checksum_store
@checksum_store ||= Checksum::Store.new
end
end
end
end
2 changes: 1 addition & 1 deletion lib/rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module Gem
# Further RubyGems documentation can be found at:
#
# * {RubyGems Guides}[https://guides.rubygems.org]
# * {RubyGems API}[https://www.rubydoc.info/github/ruby/rubygems] (also available from
# * {RubyGems API}[https://guides.rubygems.org/rubygems-org-api/] (also available from
# <tt>gem server</tt>)
#
# == RubyGems Plugins
Expand Down
Loading