diff options
| -rw-r--r-- | .github/workflows/tarball-macos.yml | 28 | ||||
| -rw-r--r-- | .github/workflows/tarball-non-development.yml | 18 | ||||
| -rw-r--r-- | .github/workflows/tarball-test.yml | 2 | ||||
| -rw-r--r-- | .github/workflows/tarball-ubuntu.yml | 67 | ||||
| -rw-r--r-- | .github/workflows/tarball-windows.yml | 32 | ||||
| -rw-r--r-- | cont.c | 2 | ||||
| -rw-r--r-- | marshal.c | 3 | ||||
| -rw-r--r-- | parse.y | 7 | ||||
| -rw-r--r-- | test/ruby/test_ast.rb | 5 | ||||
| -rw-r--r-- | test/ruby/test_marshal.rb | 14 | ||||
| -rw-r--r-- | thread_pthread.c | 20 | ||||
| -rw-r--r-- | version.h | 2 |
12 files changed, 112 insertions, 88 deletions
diff --git a/.github/workflows/tarball-macos.yml b/.github/workflows/tarball-macos.yml index e1d4d4ba2a..78cf541eab 100644 --- a/.github/workflows/tarball-macos.yml +++ b/.github/workflows/tarball-macos.yml @@ -39,12 +39,12 @@ jobs: "$@" || { sleep 5 && "$@"; } || { sleep 60 && "$@"; } } set -x - with_retry brew install gmp libffi openssl@1.1 zlib autoconf automake libtool readline libyaml + with_retry brew install gmp libffi openssl zlib autoconf automake libtool libyaml - name: Set ENV run: | echo "JOBS=-j$((1 + $(sysctl -n hw.activecpu)))" >> $GITHUB_ENV - name: configure - run: cd "$ARCHNAME/" && ./configure --with-openssl-dir=$(brew --prefix openssl@1.1) --with-readline-dir=$(brew --prefix readline) --with-libyaml-dir=$(brew --prefix libyaml) + run: cd "$ARCHNAME/" && ./configure --with-openssl-dir=$(brew --prefix openssl) --with-libyaml-dir=$(brew --prefix libyaml) - name: make run: cd "$ARCHNAME/" && make $JOBS - name: Tests @@ -68,25 +68,23 @@ jobs: /usr/local/bin/gem -v /usr/local/bin/bundle -v if: matrix.test_task == 'check' - - uses: ruby/action-slack@54175162371f1f7c8eb94d7c8644ee2479fcd375 # v3.2.2 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - payload: | - { - "ci": "GitHub Actions", - "env": "snapshot: ${{ matrix.os }} / ${{ matrix.test_task }}", - "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}", - "commit": "${{ github.sha }}", - "branch": "${{ github.ref_name }}" - } - env: - SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} - if: failure() + sparse-checkout: .github/actions/slack + sparse-checkout-cone-mode: false + persist-credentials: false + if: ${{ failure() }} + - uses: ./.github/actions/slack + with: + label: "${{ matrix.os }} / ${{ matrix.test_task }}" + SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot + if: ${{ failure() }} - uses: ruby/action-slack@54175162371f1f7c8eb94d7c8644ee2479fcd375 # v3.2.2 with: payload: | { "attachments": [{ - "text": "${{ job.status }}: ${{ matrix.os }} / ${{ matrix.test_task }} <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}>", + "text": "${{ job.status }}: ${{ matrix.os }} / ${{ matrix.test_task }} <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ inputs.archname }}>", "color": "danger" }] } diff --git a/.github/workflows/tarball-non-development.yml b/.github/workflows/tarball-non-development.yml index 09e6b44a87..154d204a2c 100644 --- a/.github/workflows/tarball-non-development.yml +++ b/.github/workflows/tarball-non-development.yml @@ -5,6 +5,13 @@ on: jobs: non_development: + strategy: + fail-fast: false + matrix: + include: + - { variant: default, remove_ruby: false, configure_extra: '' } + - { variant: no-ruby, remove_ruby: true, configure_extra: '' } + - { variant: baseruby-no, remove_ruby: false, configure_extra: '--with-baseruby=no' } runs-on: ubuntu-24.04 env: ruby_prefix: /tmp/ruby-snapshot @@ -26,12 +33,19 @@ jobs: run: | set -x sudo apt-get update -q || : - sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev bison- autoconf- + sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev zlib1g-dev libffi-dev libgmp-dev bison- autoconf- + - name: Remove host ruby + if: matrix.remove_ruby + run: | + set -x + sudo apt-get purge -y -q 'ruby*' || : + sudo rm -rf /opt/hostedtoolcache/Ruby + ! command -v ruby - name: Set ENV run: | echo "JOBS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV - name: configure - run: cd snapshot-*/ && ./configure --prefix="${ruby_prefix}" + run: cd snapshot-*/ && ./configure --prefix="${ruby_prefix}" ${{ matrix.configure_extra }} - name: make run: cd snapshot-*/ && make $JOBS - name: Leaked Globals diff --git a/.github/workflows/tarball-test.yml b/.github/workflows/tarball-test.yml index ecb2cc711d..36200809ac 100644 --- a/.github/workflows/tarball-test.yml +++ b/.github/workflows/tarball-test.yml @@ -48,7 +48,7 @@ jobs: git fetch --no-tags --depth=1 origin "+refs/heads/$BRANCH:refs/remotes/origin/$BRANCH" git checkout -B "$BRANCH" HEAD git branch --set-upstream-to="origin/$BRANCH" "$BRANCH" - - uses: ./.github/actions/make-snapshot + - uses: ruby/ruby/.github/actions/make-snapshot@master with: archname: snapshot-${{ env.BRANCH }} srcdir: '.' diff --git a/.github/workflows/tarball-ubuntu.yml b/.github/workflows/tarball-ubuntu.yml index 4e4b2cf6d0..1b21355f5a 100644 --- a/.github/workflows/tarball-ubuntu.yml +++ b/.github/workflows/tarball-ubuntu.yml @@ -34,10 +34,10 @@ jobs: run: | set -x sudo apt-get update -q - sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev bison- autoconf- - - uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f # v1.306.0 + sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev zlib1g-dev libffi-dev libgmp-dev bison- autoconf- + - uses: ruby/setup-ruby@6aaa311d81eba98ae12eaffbcb63296ace0efcde # v1.307.0 with: - ruby-version: 3.2 + ruby-version: '3.2' # test-bundled-gems requires executable host ruby if: matrix.test_task == 'test-bundled-gems' - name: Fixed world writable dirs @@ -62,8 +62,7 @@ jobs: - name: Save stats of HOME run: | set -euxo pipefail - cd "$ARCHNAME/" - cat >test.rb <<'EOF' + cat >"$ARCHNAME/save-stats.rb" <<'EOF' require 'pathname' require 'digest' out = [] @@ -82,12 +81,11 @@ jobs: out << [pn.to_s, $!.inspect].to_s end end - File.open("/tmp/stat-before-tests.txt", "w") do |io| + File.open(ARGV.shift, "w") do |io| io.puts out.sort end EOF - make runruby - rm -f test.rb + make -C "$ARCHNAME" TESTRUN_SCRIPT=save-stats.rb RUNOPT=/tmp/stat-before-tests.txt runruby - name: Tests run: cd "$ARCHNAME/" && make $JOBS -s ${{ matrix.test_task }} env: @@ -98,33 +96,8 @@ jobs: run: rm -rf $HOME/.gnupg - name: Diff stats of HOME run: | - set -euxo pipefail - cd "$ARCHNAME/" - cat >test.rb <<'EOF' - require 'pathname' - require 'digest' - out = [] - [ - Dir.home, - ].each do |dir| - Pathname(dir).each_child do |pn| - st = pn.stat - if st.file? - content = Digest::SHA1.hexdigest(pn.read) - elsif st.directory? && st.nlink <= 10 - content = pn.children.map(&:basename).map(&:to_s).sort - end - out << [pn.to_s, "%o"%st.mode, st.nlink, st.uid, st.gid, st.size, content].to_s - rescue - out << [pn.to_s, $!.inspect].to_s - end - end - File.open("/tmp/stat-after-tests.txt", "w") do |io| - io.puts out.sort - end - EOF - make runruby - rm -f test.rb + make -C "$ARCHNAME" TESTRUN_SCRIPT=save-stats.rb RUNOPT=/tmp/stat-after-tests.txt runruby + rm -f "$ARCHNAME/save-stats.rb" diff -u /tmp/stat-before-tests.txt /tmp/stat-after-tests.txt # leaked-globals since 2.7 - name: Leaked Globals @@ -144,25 +117,23 @@ jobs: if: matrix.test_task == 'check' - name: Show .local run: find $HOME/.local -ls - - uses: ruby/action-slack@54175162371f1f7c8eb94d7c8644ee2479fcd375 # v3.2.2 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - payload: | - { - "ci": "GitHub Actions", - "env": "snapshot: ${{ matrix.os }} / ${{ matrix.test_task }}", - "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}", - "commit": "${{ github.sha }}", - "branch": "${{ github.ref_name }}" - } - env: - SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} - if: failure() + sparse-checkout: .github/actions/slack + sparse-checkout-cone-mode: false + persist-credentials: false + if: ${{ failure() }} + - uses: ./.github/actions/slack + with: + label: "${{ matrix.os }} / ${{ matrix.test_task }}" + SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot + if: ${{ failure() }} - uses: ruby/action-slack@54175162371f1f7c8eb94d7c8644ee2479fcd375 # v3.2.2 with: payload: | { "attachments": [{ - "text": "${{ job.status }}: ${{ matrix.os }} / ${{ matrix.test_task }} <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}>", + "text": "${{ job.status }}: ${{ matrix.os }} / ${{ matrix.test_task }} <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ inputs.archname }}>", "color": "danger" }] } diff --git a/.github/workflows/tarball-windows.yml b/.github/workflows/tarball-windows.yml index 5d004872cf..28fbacc3c2 100644 --- a/.github/workflows/tarball-windows.yml +++ b/.github/workflows/tarball-windows.yml @@ -39,9 +39,9 @@ jobs: - run: md build working-directory: - - uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f # v1.306.0 + - uses: ruby/setup-ruby@6aaa311d81eba98ae12eaffbcb63296ace0efcde # v1.307.0 with: - ruby-version: '3.1' + ruby-version: '3.2' bundler: none windows-toolchain: none @@ -64,7 +64,7 @@ jobs: ${{ runner.os }}-vcpkg-installed- - name: Install libraries with vcpkg run: | - vcpkg --triplet x64-windows install libffi libyaml openssl readline zlib + vcpkg --triplet x64-windows install libffi libyaml openssl zlib - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: @@ -104,7 +104,7 @@ jobs: - name: link libraries run: | for %%I in (C:\vcpkg\installed\x64-windows\bin\*.dll) do ( - if not %%~nI == readline mklink %%~nxI %%I + mklink %%~nxI %%I ) - name: Configure env: @@ -130,25 +130,23 @@ jobs: timeout-minutes: 70 continue-on-error: ${{ matrix.continue-on-error || false }} - - uses: ruby/action-slack@54175162371f1f7c8eb94d7c8644ee2479fcd375 # v3.2.2 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - payload: | - { - "ci": "GitHub Actions", - "env": "snapshot: ${{ env.OS_VER }} / ${{ matrix.test_task }}", - "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}", - "commit": "${{ github.sha }}", - "branch": "${{ github.ref_name }}" - } - env: - SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} - if: failure() + sparse-checkout: .github/actions/slack + sparse-checkout-cone-mode: false + persist-credentials: false + if: ${{ failure() }} + - uses: ./.github/actions/slack + with: + label: "${{ env.OS_VER }} / ${{ matrix.test_task }}" + SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot + if: ${{ failure() }} - uses: ruby/action-slack@54175162371f1f7c8eb94d7c8644ee2479fcd375 # v3.2.2 with: payload: | { "attachments": [{ - "text": "${{ job.status }}: ${{ env.OS_VER }} / ${{ matrix.test_task }} <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}>", + "text": "${{ job.status }}: ${{ env.OS_VER }} / ${{ matrix.test_task }} <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ inputs.archname }}>", "color": "danger" }] } @@ -2724,7 +2724,7 @@ fiber_switch(rb_fiber_t *fiber, int argc, const VALUE *argv, int kw_splat, rb_fi // We cannot free the stack until the pthread is joined: #ifndef COROUTINE_PTHREAD_CONTEXT - if (resuming_fiber && FIBER_TERMINATED_P(fiber)) { + if (FIBER_TERMINATED_P(fiber)) { fiber_stack_release(fiber); } #endif @@ -1874,6 +1874,9 @@ r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE extmod, int typ } v = (VALUE)link; if (!st_lookup(arg->partial_objects, (st_data_t)v, &link)) { + if (arg->freeze && RB_TYPE_P(v, T_STRING)) { + v = rb_str_to_interned_str(v); + } v = r_post_proc(v, arg); } break; @@ -1435,7 +1435,7 @@ static NODE *new_hash_pattern_tail(struct parser_params *p, NODE *kw_args, ID kw static rb_node_kw_arg_t *new_kw_arg(struct parser_params *p, NODE *k, const YYLTYPE *loc); static rb_node_args_t *args_with_numbered(struct parser_params*,rb_node_args_t*,int,ID); -static NODE* negate_lit(struct parser_params*, NODE*); +static NODE* negate_lit(struct parser_params*, NODE*,const YYLTYPE*); static NODE *ret_args(struct parser_params*,NODE*); static NODE *arg_blk_pass(NODE*,rb_node_block_pass_t*); static NODE *new_yield(struct parser_params*,NODE*,const YYLTYPE*); @@ -6263,7 +6263,7 @@ numeric : simple_numeric | tUMINUS_NUM simple_numeric %prec tLOWEST { $$ = $2; - negate_lit(p, $$); + negate_lit(p, $$, &@$); /*% ripper: unary!(ID2VAL(idUMinus), $:2) %*/ } ; @@ -14409,7 +14409,7 @@ new_yield(struct parser_params *p, NODE *node, const YYLTYPE *loc) } static NODE* -negate_lit(struct parser_params *p, NODE* node) +negate_lit(struct parser_params *p, NODE* node, const YYLTYPE *loc) { switch (nd_type(node)) { case NODE_INTEGER: @@ -14425,6 +14425,7 @@ negate_lit(struct parser_params *p, NODE* node) RNODE_IMAGINARY(node)->minus = TRUE; break; } + node->nd_loc = *loc; return node; } diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb index a183601b56..b3f44091eb 100644 --- a/test/ruby/test_ast.rb +++ b/test/ruby/test_ast.rb @@ -1496,6 +1496,11 @@ dummy assert_locations(node.children[-1].locations, [[1, 0, 1, 9], [1, 2, 1, 7], nil]) end + def test_negative_numeric_locations + node = ast_parse("-1") + assert_locations(node.children.last.locations, [[1, 0, 1, 2]]) + end + private def ast_parse(src, **options) begin diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb index 0e19349ea6..2c1bb858d4 100644 --- a/test/ruby/test_marshal.rb +++ b/test/ruby/test_marshal.rb @@ -979,5 +979,19 @@ class TestMarshal < Test::Unit::TestCase refute_predicate Object, :frozen? refute_predicate Kernel, :frozen? end + + def test_linked_strings_are_frozen + str = "test" + str.instance_variable_set(:@self, str) + source = [str, str] + + objects = Marshal.load(encode(source), freeze: true) + assert_predicate objects[0], :frozen? + assert_predicate objects[1], :frozen? + assert_same objects[0], objects[1] + assert_same objects[0], objects[0].instance_variable_get(:@self) + assert_same objects[1], objects[1].instance_variable_get(:@self) + assert_same objects[0].instance_variable_get(:@self), objects[1].instance_variable_get(:@self) + end end end diff --git a/thread_pthread.c b/thread_pthread.c index 8ba1ad48d3..7957b18c7b 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1533,6 +1533,8 @@ get_native_thread_id(void) #endif #if defined(HAVE_WORKING_FORK) +void rb_internal_thread_event_hooks_rw_lock_atfork(void); + static void thread_sched_atfork(struct rb_thread_sched *sched) { @@ -1564,6 +1566,8 @@ thread_sched_atfork(struct rb_thread_sched *sched) ccan_list_head_init(&vm->ractor.sched.timeslice_threads); ccan_list_head_init(&vm->ractor.sched.running_threads); + rb_internal_thread_event_hooks_rw_lock_atfork(); + VM_ASSERT(sched->is_running); sched->is_running_timeslice = false; @@ -3354,6 +3358,22 @@ struct rb_internal_thread_event_hook { static pthread_rwlock_t rb_internal_thread_event_hooks_rw_lock = PTHREAD_RWLOCK_INITIALIZER; +#if defined(HAVE_WORKING_FORK) +void +rb_internal_thread_event_hooks_rw_lock_atfork(void) +{ + // After fork(), this rwlock may have been held by a now-dead thread. + // + // pthread_rwlock_destroy() on a held lock is undefined behavior, and + // pthread_rwlock_init() on an already-initialized lock is also undefined + // behavior + // + // Direct assignment of PTHREAD_RWLOCK_INITIALIZER is safe and portable. + rb_internal_thread_event_hooks_rw_lock = + (pthread_rwlock_t)PTHREAD_RWLOCK_INITIALIZER; +} +#endif + rb_internal_thread_event_hook_t * rb_internal_thread_add_event_hook(rb_internal_thread_event_callback callback, rb_event_flag_t internal_event, void *user_data) { @@ -11,7 +11,7 @@ # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 9 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 87 +#define RUBY_PATCHLEVEL 91 #include "ruby/version.h" #include "ruby/internal/abi.h" |
