Skip to content

imemo_fields: store owner object in RBasic.klass #14147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

casperisfine
Copy link
Contributor

Followup on #14146

It is much more convenient than storing the klass, especially when dealing with object_id as it allows to update the id2ref table without having to dereference the owner, which may be garbage at that point.

byroot added 2 commits August 8, 2025 09:15
Given `ObjectSpace._id2ref` is a deprecated API, it is assumed
it won't ever be called, hence we optimistically don't keep
an `id -> ref` mapping.

So when `object_id_to_ref` is called for the first time, we go
over the entire heap to build that missing table.

At that point we must be very careful about garbage objects.
If they have an object id, the GC will attempt to remove them
from the `id2ref` table when sweeping them.

Until now, the strategy was to insert them anyway, but this
actually cause issue with objects that rely on `IMEMO/fields`
because the object fields may be already sweeped (hence ASAN poisoned).

Unfortunately I'm not able to craft a reproduction script to
validate this theory, as the GC need to be in a precise state
for the bug to happen.
It is much more convenient than storing the klass, especially
when dealing with `object_id` as it allows to update the id2ref
table without having to dereference the owner, which may be
garbage at that point.
@byroot
Copy link
Member

byroot commented Aug 13, 2025

Superseeded by #14202

@byroot byroot closed this Aug 13, 2025
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