Skip to content

Check for NULL fields in TYPEDDATA memsize functions#15633

Merged
luke-gru merged 1 commit intoruby:masterfrom
luke-gruber:typeddata_memsize_check_null_fields
Dec 18, 2025
Merged

Check for NULL fields in TYPEDDATA memsize functions#15633
luke-gru merged 1 commit intoruby:masterfrom
luke-gruber:typeddata_memsize_check_null_fields

Conversation

@luke-gruber
Copy link
Copy Markdown
Contributor

Some TYPEDDATA objects allocate struct fields using the GC right after they get created, and in that case the VM can try to perform a GC and join a barrier if another ractor started one. If we're dumping the heap in another ractor, this acquires a barrier and it will call the rb_obj_memsize function on this object. We can't assume these struct fields are non-null. This also goes for C extensions, which may cause problems with heap dumping from a ractor if their memsize functions aren't coded correctly to check for NULL fields. Because dumping the heap from a ractor is likely a rare scenario and it has only recently been introduced, we'll have to see how this works in practice and if it causes bugs.

Some TYPEDDATA objects allocate struct fields using the GC right after
they get created, and in that case the VM can try to perform a GC and join
a barrier if another ractor started one. If we're dumping the heap in another
ractor, this acquires a barrier and it will call the `rb_obj_memsize` function on this
object. We can't assume these struct fields are non-null. This also goes for C extensions,
which may cause problems with heap dumping from a ractor if their memsize functions aren't
coded correctly to check for NULL fields. Because dumping the heap from a ractor is likely a
rare scenario and it has only recently been introduced, we'll have to see how this works in
practice and if it causes bugs.
@luke-gru luke-gru requested a review from jhawthorn December 18, 2025 18:16
@luke-gru luke-gru merged commit aace29d into ruby:master Dec 18, 2025
92 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.

4 participants