Skip to content

Conversation

@VanshAgarwal24036
Copy link
Contributor

@VanshAgarwal24036 VanshAgarwal24036 commented Feb 9, 2026

Fix a potential use-after-free when storing or deleting instance attributes if a re-entrant __hash__ mutates the instance __dict__ during attribute handling.

Temporarily INCREF the managed dict in the Py_GIL_DISABLED path to ensure it remains alive across the call to store_instance_attr_dict().

@picnixz
Copy link
Member

picnixz commented Feb 10, 2026

What is the performance impact on this change? @kumaraditya303 hinted that this could add overhead (probably in free-threaded build) so I wpuld like that you first read the concerns on the issue before jumping on the PR. Serhiy also suggested an alternative.

@picnixz
Copy link
Member

picnixz commented Feb 10, 2026

FTR this could impact dataclass creations, namedtuple creations and other types that are dynamically created or that heavily use setattr/delattr explicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants