Skip to content

Avoid dispatch in ERB initialization guard#124

Merged
k0kubun merged 2 commits into
ruby:masterfrom
k0kubun:harden-init-guard
Jul 16, 2026
Merged

Avoid dispatch in ERB initialization guard#124
k0kubun merged 2 commits into
ruby:masterfrom
k0kubun:harden-init-guard

Conversation

@k0kubun

@k0kubun k0kubun commented Jul 16, 2026

Copy link
Copy Markdown
Member

The guard for methods that eval ERB source compared @_init with self.class.singleton_class by calling equal? on @_init. A marshal-loaded object can control @_init, so make the comparison through BasicObject#equal? directly instead of dispatching to the restored object.

This keeps normal ERB instances working while preserving the ArgumentError for marshal-loaded instances.

k0kubun added 2 commits July 16, 2026 13:36
The guard for methods that eval ERB source compared @_init with self.class.singleton_class by calling equal? on @_init. A marshal-loaded object can control @_init, so make the comparison through BasicObject#equal? directly instead of dispatching to the restored object.

This keeps normal ERB instances working while preserving the ArgumentError for marshal-loaded instances.
@k0kubun
k0kubun merged commit ce08ffb into ruby:master Jul 16, 2026
9 checks passed
@k0kubun
k0kubun deleted the harden-init-guard branch July 16, 2026 20:45
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.

1 participant