Skip to content

Set the pin bit on pinned roots during moving GCs - #133

Open
eightbitraptor wants to merge 2 commits into
mainfrom
mvh-fix-root-pinned
Open

eightbitraptor wants to merge 2 commits into
mainfrom
mvh-fix-root-pinned

Conversation

@eightbitraptor

Copy link
Copy Markdown
Member

Roots reported through rb_gc_impl_mark_and_pin and rb_gc_impl_mark_maybe were processed as pinning roots. That keeps them in place for the current GC, but it does not set the pin bit, so rb_gc_impl_pinned_p returned false for them. When it updates references, Ruby re-embeds strings and arrays whose pinned_p is false and frees their heap buffer, even when a C frame still holds RSTRING_PTR.

Since ruby/ruby 0b7838e23b, File.read returns a heap string that fits its slot, so String#scan in template/exts.mk.tmpl raised "string modified" under Immix and StickyImmix.

In this commit we set the pin bit on roots reported with pin during moving GCs, and record them in the PinningRegistry so that the existing UnpinPinnedObjects work unpins them in VMRefClosure. Roots marked with rb_gc_mark_movable stay movable, so they can still be re-embedded.

Roots reported through rb_gc_impl_mark_and_pin and
rb_gc_impl_mark_maybe were processed as pinning roots. That keeps them
in place for the current GC, but it does not set the pin bit, so
rb_gc_impl_pinned_p returned false for them. When it updates references,
Ruby re-embeds strings and arrays whose pinned_p is false and frees
their heap buffer, even when a C frame still holds RSTRING_PTR.

Since ruby/ruby 0b7838e23b, File.read returns a heap string that fits
its slot, so String#scan in template/exts.mk.tmpl raised "string
modified" under Immix and StickyImmix.

In this commit we set the pin bit on roots reported with pin during
moving GCs, and record them in the PinningRegistry so that the existing
UnpinPinnedObjects work unpins them in VMRefClosure. Roots marked with
rb_gc_mark_movable stay movable, so they can still be re-embedded.
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