Skip to content

Commit 203cbe3

Browse files
authored
Merge branch 'master' into jit-ci-crash-report
2 parents 35cf12f + 3c7a897 commit 203cbe3

88 files changed

Lines changed: 859 additions & 1979 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/capiext/action.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,34 @@ runs:
5050
touch spec/ruby/optional/capi/ext/*.$DLEXT
5151
[ ! -f spec/ruby/optional/capi/ext/\*.$DLEXT ]
5252
${{ inputs.make }} SPECOPTS=optional/capi test-spec
53-
rm -f spec/ruby/optional/capi/ext/*.c
5453
env:
5554
DLEXT: ${{ steps.config.outputs.DLEXT }}
5655
working-directory: ${{ inputs.builddir }}
5756
if: ${{ steps.cache.outputs.cache-hit }}
5857

59-
- name: Save CAPI extensions
60-
uses: actions/cache/save@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
61-
with:
62-
path: ${{ inputs.builddir }}/spec/ruby/optional/capi/ext/
63-
key: ${{ steps.config.outputs.key }}
58+
- name: Strip CAPI extensions
59+
id: strip
60+
shell: bash
61+
run: |
62+
rm -f spec/ruby/optional/capi/ext/*.c
63+
[ "$DLEXT" = bundle ] || # separated to .dSYM directories
64+
strip spec/ruby/optional/capi/ext/*.$DLEXT
65+
env:
66+
DLEXT: ${{ steps.config.outputs.DLEXT }}
67+
working-directory: ${{ inputs.builddir }}
6468
if: >-
6569
${{true
66-
&& steps.cache.outcome == 'success'
6770
&& ! steps.cache.outputs.cache-hit
6871
&& github.ref_name == 'master'
6972
}}
7073
74+
- name: Save CAPI extensions
75+
uses: actions/cache/save@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
76+
with:
77+
path: ${{ inputs.builddir }}/spec/ruby/optional/capi/ext/
78+
key: ${{ steps.config.outputs.key }}
79+
if: ${{ steps.strip.outcome == 'success' }}
80+
7181
- shell: bash
7282
run: |
7383
echo "::error::Change from ${prev} detected; bump up ABI version"

.github/workflows/ubuntu.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ jobs:
4040
- test_task: check
4141
os: ubuntu-24.04
4242
extra_checks: [capi]
43-
# ubuntu-24.04-arm jobs don't start on ruby/ruby as of 2025-09-04
44-
#- test_task: check
45-
# os: ubuntu-24.04-arm
43+
- test_task: check
44+
os: ubuntu-24.04-arm
45+
extra_checks: [capi]
4646
fail-fast: false
4747

4848
env:

array.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,11 @@ ary_alloc_heap(VALUE klass)
695695
NEWOBJ_OF(ary, struct RArray, klass,
696696
T_ARRAY | (RGENGC_WB_PROTECTED_ARRAY ? FL_WB_PROTECTED : 0),
697697
sizeof(struct RArray), 0);
698+
699+
ary->as.heap.len = 0;
700+
ary->as.heap.aux.capa = 0;
701+
ary->as.heap.ptr = NULL;
702+
698703
return (VALUE)ary;
699704
}
700705

@@ -808,6 +813,11 @@ ec_ary_alloc_heap(rb_execution_context_t *ec, VALUE klass)
808813
NEWOBJ_OF(ary, struct RArray, klass,
809814
T_ARRAY | (RGENGC_WB_PROTECTED_ARRAY ? FL_WB_PROTECTED : 0),
810815
sizeof(struct RArray), ec);
816+
817+
ary->as.heap.len = 0;
818+
ary->as.heap.aux.capa = 0;
819+
ary->as.heap.ptr = NULL;
820+
811821
return (VALUE)ary;
812822
}
813823

bignum.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3055,7 +3055,9 @@ bignew_1(VALUE klass, size_t len, int sign)
30553055
VALUE
30563056
rb_big_new(size_t len, int sign)
30573057
{
3058-
return bignew(len, sign != 0);
3058+
VALUE obj = bignew(len, sign != 0);
3059+
memset(BIGNUM_DIGITS(obj), 0, len * sizeof(BDIGIT));
3060+
return obj;
30593061
}
30603062

30613063
VALUE

class.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,8 @@ class_alloc0(enum ruby_value_type type, VALUE klass, bool namespaceable)
682682

683683
NEWOBJ_OF(obj, struct RClass, klass, flags, alloc_size, 0);
684684

685+
obj->object_id = 0;
686+
685687
memset(RCLASS_EXT_PRIME(obj), 0, sizeof(rb_classext_t));
686688

687689
/* ZALLOC

common.mk

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ RUBYLIB = $(PATH_SEPARATOR)
4444
RUBYOPT = -
4545
RUN_OPTS = --disable-gems
4646

47+
GIT_IN_SRC = $(GIT) -C $(srcdir)
48+
GIT_LOG = $(GIT_IN_SRC) log --no-show-signature
49+
GIT_LOG_FORMAT = $(GIT_LOG) --pretty=format:
50+
4751
# GITPULLOPTIONS = --no-tags
4852

4953
PRISM_SRCDIR = $(srcdir)/prism
@@ -1514,8 +1518,8 @@ update-bundled_gems: PHONY
15141518
$(tooldir)/update-bundled_gems.rb \
15151519
"$(srcdir)/gems/bundled_gems" | \
15161520
$(IFCHANGE) "$(srcdir)/gems/bundled_gems" -
1517-
$(GIT) -C "$(srcdir)" diff --no-ext-diff --ignore-submodules --exit-code || \
1518-
$(GIT) -C "$(srcdir)" commit -m "Update bundled_gems" gems/bundled_gems
1521+
$(GIT_IN_SRC) diff --no-ext-diff --ignore-submodules --exit-code || \
1522+
$(GIT_IN_SRC) commit -m "Update bundled_gems" gems/bundled_gems
15191523

15201524
PRECHECK_BUNDLED_GEMS = yes
15211525
test-bundled-gems-precheck: $(TEST_RUNNABLE)-test-bundled-gems-precheck
@@ -1899,8 +1903,8 @@ nightly: yesterday $(DOT_WAIT) install
18991903
yesterday: rewindable
19001904

19011905
rewindable:
1902-
$(GIT) -C $(srcdir) status --porcelain
1903-
$(GIT) -C $(srcdir) diff --quiet
1906+
$(GIT_IN_SRC) status --porcelain
1907+
$(GIT_IN_SRC) diff --quiet
19041908

19051909
HELP_EXTRA_TASKS = ""
19061910

configure.ac

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,18 @@ HAVE_GIT=yes
107107
AC_ARG_WITH(git,
108108
AS_HELP_STRING([--without-git], [never use git]),
109109
[AS_CASE([$withval],
110-
[no], [GIT=never-use HAVE_GIT=no],
110+
[no], [HAVE_GIT=no],
111111
[yes], [],
112112
[GIT=$withval])])
113-
AS_IF([test x"$HAVE_GIT" = xyes], [command -v "$GIT" > /dev/null || HAVE_GIT=no])
113+
{
114+
test x"$HAVE_GIT" = xyes &&
115+
command -v "$GIT" > /dev/null &&
116+
# `git -C`: 1.8.5
117+
# `git log --no-show-signature`: 2.10.0
118+
AS_CASE([`$GIT -C . --version 2> /dev/null | sed 's/.* //'`],
119+
[0.*|1.*|2.@<:@0-9@:>@.*], [false],
120+
[true])
121+
} || HAVE_GIT=no GIT=never-use
114122
AC_SUBST(GIT)
115123
AC_SUBST(HAVE_GIT)
116124

@@ -3966,7 +3974,7 @@ AS_CASE(["${ZJIT_SUPPORT}"],
39663974
[yes], [
39673975
],
39683976
[dev], [
3969-
rb_cargo_features="$rb_cargo_features,disasm"
3977+
rb_cargo_features="$rb_cargo_features,disasm,runtime_checks"
39703978
JIT_CARGO_SUPPORT=dev
39713979
AC_DEFINE(RUBY_DEBUG, 1)
39723980
],

defs/gmake.mk

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ post-commit: $(if $(DOT_WAIT),,do-commit)
220220
GITHUB_RUBY_URL = https://github.com/ruby/ruby
221221
PR =
222222

223-
COMMIT_GPG_SIGN = $(shell $(GIT) -C "$(srcdir)" config commit.gpgsign)
224-
REMOTE_GITHUB_URL = $(shell $(GIT) -C "$(srcdir)" config remote.github.url)
223+
COMMIT_GPG_SIGN = $(shell $(GIT_IN_SRC) config commit.gpgsign)
224+
REMOTE_GITHUB_URL = $(shell $(GIT_IN_SRC) config remote.github.url)
225225
COMMITS_NOTES = commits
226226

227227
.PHONY: fetch-github
@@ -236,19 +236,19 @@ define fetch-github
236236
$(eval REMOTE_GITHUB_URL := $(REMOTE_GITHUB_URL))
237237
$(if $(REMOTE_GITHUB_URL),,
238238
echo adding $(GITHUB_RUBY_URL) as remote github
239-
$(GIT) -C "$(srcdir)" remote add github $(GITHUB_RUBY_URL)
240-
$(GIT) -C "$(srcdir)" config --add remote.github.fetch +refs/notes/$(COMMITS_NOTES):refs/notes/$(COMMITS_NOTES)
239+
$(GIT_IN_SRC) remote add github $(GITHUB_RUBY_URL)
240+
$(GIT_IN_SRC) config --add remote.github.fetch +refs/notes/$(COMMITS_NOTES):refs/notes/$(COMMITS_NOTES)
241241
$(eval REMOTE_GITHUB_URL := $(GITHUB_RUBY_URL))
242242
)
243-
$(if $(shell $(GIT) -C "$(srcdir)" rev-parse "github/pull/$(1)/head" -- 2> /dev/null),
244-
$(GIT) -C "$(srcdir)" branch -f "gh-$(1)" "github/pull/$(1)/head",
245-
$(GIT) -C "$(srcdir)" fetch -f github "pull/$(1)/head:gh-$(1)"
243+
$(if $(shell $(GIT_IN_SRC) rev-parse "github/pull/$(1)/head" -- 2> /dev/null),
244+
$(GIT_IN_SRC) branch -f "gh-$(1)" "github/pull/$(1)/head",
245+
$(GIT_IN_SRC) fetch -f github "pull/$(1)/head:gh-$(1)"
246246
)
247247
endef
248248

249249
.PHONY: checkout-github
250250
checkout-github: fetch-github
251-
$(GIT) -C "$(srcdir)" checkout "gh-$(PR)"
251+
$(GIT_IN_SRC) checkout "gh-$(PR)"
252252

253253
.PHONY: update-github
254254
update-github: fetch-github
@@ -261,25 +261,25 @@ update-github: fetch-github
261261
$(eval PR_BRANCH := $(word 2,$(PULL_REQUEST_FORK_BRANCH)))
262262

263263
$(eval GITHUB_UPDATE_WORKTREE := $(shell mktemp -d "$(srcdir)/gh-$(PR)-XXXXXX"))
264-
$(GIT) -C "$(srcdir)" worktree add $(notdir $(GITHUB_UPDATE_WORKTREE)) "gh-$(PR)"
264+
$(GIT_IN_SRC) worktree add $(notdir $(GITHUB_UPDATE_WORKTREE)) "gh-$(PR)"
265265
$(GIT) -C "$(GITHUB_UPDATE_WORKTREE)" merge master --no-edit
266266
@$(BASERUBY) -e 'print "Are you sure to push this to PR=$(PR)? [Y/n]: "; exit(gets.chomp != "n")'
267-
$(GIT) -C "$(srcdir)" remote add fork-$(PR) git@github.com:$(FORK_REPO).git
267+
$(GIT_IN_SRC) remote add fork-$(PR) git@github.com:$(FORK_REPO).git
268268
$(GIT) -C "$(GITHUB_UPDATE_WORKTREE)" push fork-$(PR) gh-$(PR):$(PR_BRANCH)
269-
$(GIT) -C "$(srcdir)" remote rm fork-$(PR)
270-
$(GIT) -C "$(srcdir)" worktree remove $(notdir $(GITHUB_UPDATE_WORKTREE))
271-
$(GIT) -C "$(srcdir)" branch -D gh-$(PR)
269+
$(GIT_IN_SRC) remote rm fork-$(PR)
270+
$(GIT_IN_SRC) worktree remove $(notdir $(GITHUB_UPDATE_WORKTREE))
271+
$(GIT_IN_SRC) branch -D gh-$(PR)
272272

273273
.PHONY: pull-github
274274
pull-github: fetch-github
275275
$(call pull-github,$(PR))
276276

277277
define pull-github
278-
$(eval GITHUB_MERGE_BASE := $(shell $(GIT) -C "$(srcdir)" log -1 --format=format:%H))
279-
$(eval GITHUB_MERGE_BRANCH := $(shell $(GIT) -C "$(srcdir)" symbolic-ref --short HEAD))
278+
$(eval GITHUB_MERGE_BASE := $(shell $(GIT_LOG_FORMAT):%H -1)
279+
$(eval GITHUB_MERGE_BRANCH := $(shell $(GIT_IN_SRC) symbolic-ref --short HEAD))
280280
$(eval GITHUB_MERGE_WORKTREE := $(shell mktemp -d "$(srcdir)/gh-$(1)-XXXXXX"))
281-
$(GIT) -C "$(srcdir)" worktree prune
282-
$(GIT) -C "$(srcdir)" worktree add $(notdir $(GITHUB_MERGE_WORKTREE)) "gh-$(1)"
281+
$(GIT_IN_SRC) worktree prune
282+
$(GIT_IN_SRC) worktree add $(notdir $(GITHUB_MERGE_WORKTREE)) "gh-$(1)"
283283
$(GIT) -C "$(GITHUB_MERGE_WORKTREE)" rebase $(GITHUB_MERGE_BRANCH)
284284
$(eval COMMIT_GPG_SIGN := $(COMMIT_GPG_SIGN))
285285
$(if $(filter true,$(COMMIT_GPG_SIGN)), \
@@ -294,7 +294,7 @@ fetch-github-%:
294294
295295
.PHONY: checkout-github-%
296296
checkout-github-%: fetch-github-%
297-
$(GIT) -C "$(srcdir)" checkout "gh-$*"
297+
$(GIT_IN_SRC) checkout "gh-$*"
298298
299299
.PHONY: pr-% pull-github-%
300300
pr-% pull-github-%: fetch-github-%
@@ -433,7 +433,7 @@ ifneq ($(DOT_WAIT),)
433433
endif
434434

435435
ifeq ($(HAVE_GIT),yes)
436-
REVISION_LATEST := $(shell $(CHDIR) $(srcdir) && $(GIT) log -1 --format=%H 2>/dev/null)
436+
REVISION_LATEST := $(shell $(GIT_LOG_FORMAT)%H -1 2>/dev/null)
437437
else
438438
REVISION_LATEST := update
439439
endif
@@ -495,7 +495,7 @@ endif
495495
update-deps:
496496
$(eval update_deps := $(shell date +update-deps-%Y%m%d))
497497
$(eval deps_dir := $(shell mktemp -d)/$(update_deps))
498-
$(eval GIT_DIR := $(shell $(GIT) -C $(srcdir) rev-parse --absolute-git-dir))
498+
$(eval GIT_DIR := $(shell $(GIT_IN_SRC) rev-parse --absolute-git-dir))
499499
$(GIT) --git-dir=$(GIT_DIR) worktree add $(deps_dir)
500500
cp $(tooldir)/config.guess $(tooldir)/config.sub $(deps_dir)/tool
501501
[ -f config.status ] && cp config.status $(deps_dir)
@@ -543,13 +543,13 @@ matz: up
543543
$(eval NEW := $(MAJOR).$(MINOR).0)
544544
$(eval message := Development of $(NEW) started.)
545545
$(eval files := include/ruby/version.h include/ruby/internal/abi.h)
546-
$(GIT) -C $(srcdir) mv -f NEWS.md doc/NEWS/NEWS-$(OLD).md
547-
$(GIT) -C $(srcdir) commit -m "[DOC] Flush NEWS.md"
546+
$(GIT_IN_SRC) mv -f NEWS.md doc/NEWS/NEWS-$(OLD).md
547+
$(GIT_IN_SRC) commit -m "[DOC] Flush NEWS.md"
548548
sed -i~ \
549549
-e "s/^\(#define RUBY_API_VERSION_MINOR\) .*/\1 $(MINOR)/" \
550550
-e "s/^\(#define RUBY_ABI_VERSION\) .*/\1 0/" \
551551
$(files:%=$(srcdir)/%)
552-
$(GIT) -C $(srcdir) add $(files)
552+
$(GIT_IN_SRC) add $(files)
553553
$(BASERUBY) -C $(srcdir) -p -00 \
554554
-e 'BEGIN {old, new = ARGV.shift(2); STDOUT.reopen("NEWS.md")}' \
555555
-e 'case $$.' \
@@ -559,8 +559,8 @@ matz: up
559559
-e 'next if /^[\[ *]/ =~ $$_' \
560560
-e '$$_.sub!(/\n{2,}\z/, "\n\n")' \
561561
$(OLD) $(NEW) doc/NEWS/NEWS-$(OLD).md
562-
$(GIT) -C $(srcdir) add NEWS.md
563-
$(GIT) -C $(srcdir) commit -m "$(message)"
562+
$(GIT_IN_SRC) add NEWS.md
563+
$(GIT_IN_SRC) commit -m "$(message)"
564564

565565
tags:
566566
$(MAKE) GIT="$(GIT)" -C "$(srcdir)" -f defs/tags.mk

ext/openssl/ossl_cipher.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
*/
3333
static VALUE cCipher;
3434
static VALUE eCipherError;
35+
static VALUE eAuthTagError;
3536
static ID id_auth_tag_len, id_key_set;
3637

3738
static VALUE ossl_cipher_alloc(VALUE klass);
@@ -415,8 +416,17 @@ ossl_cipher_final(VALUE self)
415416

416417
GetCipher(self, ctx);
417418
str = rb_str_new(0, EVP_CIPHER_CTX_block_size(ctx));
418-
if (!EVP_CipherFinal_ex(ctx, (unsigned char *)RSTRING_PTR(str), &out_len))
419-
ossl_raise(eCipherError, NULL);
419+
if (!EVP_CipherFinal_ex(ctx, (unsigned char *)RSTRING_PTR(str), &out_len)) {
420+
/* For AEAD ciphers, this is likely an authentication failure */
421+
if (EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER) {
422+
/* For AEAD ciphers, EVP_CipherFinal_ex failures are authentication tag verification failures */
423+
ossl_raise(eAuthTagError, "AEAD authentication tag verification failed");
424+
}
425+
else {
426+
/* For non-AEAD ciphers */
427+
ossl_raise(eCipherError, "cipher final failed");
428+
}
429+
}
420430
assert(out_len <= RSTRING_LEN(str));
421431
rb_str_set_len(str, out_len);
422432

@@ -1027,6 +1037,7 @@ Init_ossl_cipher(void)
10271037
*/
10281038
cCipher = rb_define_class_under(mOSSL, "Cipher", rb_cObject);
10291039
eCipherError = rb_define_class_under(cCipher, "CipherError", eOSSLError);
1040+
eAuthTagError = rb_define_class_under(cCipher, "AuthTagError", eCipherError);
10301041

10311042
rb_define_alloc_func(cCipher, ossl_cipher_alloc);
10321043
rb_define_method(cCipher, "initialize_copy", ossl_cipher_copy, 1);

0 commit comments

Comments
 (0)