Skip to content

Fix Data subclasses with ivars#9181

Merged
headius merged 2 commits intojruby:ruby-4.0from
headius:data_ivar_fixes
Feb 3, 2026
Merged

Fix Data subclasses with ivars#9181
headius merged 2 commits intojruby:ruby-4.0from
headius:data_ivar_fixes

Conversation

@headius
Copy link
Member

@headius headius commented Jan 15, 2026

Data subclasses were set up to copy their parent class's var table manager and accessors, but did not overwrite those copies' realClass to the new class. This resulted in future variable accesses potentially walking back to the parent class, seeing an incorrect var table size, and allocating the wrong size table for the spilled instance variables.

The new logic does that copying with the new realClass in hand and properly replaces it in the copied accesses and manager.

This fixes all remaining issues marshaling Data with Psych and may fix other issues with Data subclasses that are not currently showing up in tests.

Data subclasses were set up to copy their parent class's var table
manager and accessors, but did not overwrite those copies'
realClass to the new class. This resulted in future variable
accesses potentially walking back to the parent class, seeing an
incorrect var table size, and allocating the wrong size table for
the spilled instance variables.

The new logic does that copying with the new realClass in hand and
properly replaces it in the copied accesses and manager.

This fixes all remaining issues marshaling Data with Psych and may
fix other issues with Data subclasses that are not currently
showing up in tests.
@headius headius added this to the JRuby 10.1.0.0 milestone Jan 15, 2026
@headius headius merged commit 75b6d59 into jruby:ruby-4.0 Feb 3, 2026
1 of 76 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.

1 participant