Skip to content

Keep ob_tid, ob_ref_local, and ob_ref_shared fields valid across allocations in free-threaded build #115491

Description

@colesbury

Feature or enhancement

The free-threaded implementation of dict and list try avoid acquiring locks during read operations. To support this, we need to be able to access the reference count fields of Python objects after they are deallocated (and possibly reallocated). Some of this support is provided by #115103. Additionally, we need to ensure that the debug allocators do not overwrite these fields with "dead" bytes 0xDD, which might make the object look "alive" by having a non-zero reference count.

We still would like to overwrite the rest of the allocation (i.e., from ob_type onwards) to detect use-after-frees in debug builds.

See also: https://peps.python.org/pep-0703/#optimistically-avoiding-locking

Linked PRs

Activity

  1. self-assigned this
    on Feb 15, 2024
  2. added 4 commits that reference this issue on Feb 16, 2024
  3. added a commit that references this issue on Feb 21, 2024
  4. colesbury commented on Feb 21, 2024

    @colesbury
    ContributorAuthor

    This still needs the mimalloc support in #115103 to fully preserve the fields, but the changes to filling debug bytes is done now.

  5. added a commit that references this issue on Feb 29, 2024
  6. added a commit that references this issue on Mar 1, 2024
  7. added 3 commits that reference this issue on Mar 4, 2024
  8. added a commit that references this issue on Mar 25, 2024
  9. added 3 commits that reference this issue on Apr 17, 2024
  10. added 2 commits that reference this issue on Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions