Skip to content

Iterate the options of pkey_ctx_apply_options without calling #each - #1161

Merged
rhenium merged 1 commit into
ruby:masterfrom
mame:pkey-options-foreach
Nov 23, 2026
Merged

rhenium merged 1 commit into
ruby:masterfrom
mame:pkey-options-foreach

Conversation

@mame

@mame mame commented Nov 20, 2026

Copy link
Copy Markdown
Member

The block given to #each carried the EVP_PKEY_CTX pointer, so a Hash subclass that overrides #each could retain the block and call it after the context was freed. Iterate the Hash with rb_hash_foreach instead.

@rhenium

rhenium commented Nov 23, 2026

Copy link
Copy Markdown
Member

Thanks for the catch!

I've opened an issue for the CI failure with TruffleRuby: truffleruby/truffleruby#4586

The block given to #each carried the EVP_PKEY_CTX pointer, so a Hash
subclass that overrides #each could retain the block and call it after
the context was freed.  Iterate the Hash with rb_hash_foreach instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rhenium
rhenium force-pushed the pkey-options-foreach branch from f947411 to 4a1ef4c Compare November 23, 2026 16:37
@rhenium

rhenium commented Nov 23, 2026

Copy link
Copy Markdown
Member

I simply omitted the test for TruffleRuby for now, since this shouldn't be an issue in normal usage.

@rhenium
rhenium merged commit 5023cb2 into ruby:master Nov 23, 2026
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants