Skip to content

Need to defer GC tracking of frozenset/set construction #152235

Closed

Description

@corona10

The same bug affects frozenset/set: construction GC-tracks the object before it's filled, so another thread can reach a half-built frozenset via gc.get_objects() mid-construction. ThreadSanitizer confirms it:

WARNING: ThreadSanitizer: data race (pid=78348)
SUMMARY: ThreadSanitizer: data race setobject.c:320 in set_add_entry_takeref
WARNING: ThreadSanitizer: data race (pid=78348)
SUMMARY: ThreadSanitizer: data race setobject.c:321 in set_add_entry_takeref
WARNING: ThreadSanitizer: data race (pid=78348)
SUMMARY: ThreadSanitizer: data race setobject.c:323 in set_add_entry_takeref
WARNING: ThreadSanitizer: data race (pid=78348)
SUMMARY: ThreadSanitizer: data race setobject.c:537 in set_table_resize
SUMMARY: ThreadSanitizer: SEGV setobject.c:816 in set_repr

I am working on this

Linked PRs

Activity

  1. self-assigned this
    on Jun 25, 2026
  2. changed the title [-]Need to defer GC tracking of frozenset construction[/-] [+]Need to defer GC tracking of frozenset/set construction[/+] on Jun 25, 2026
  3. added
    3.14bugs and security fixes
    3.15bugs and security fixes
    3.16new features, bugs and security fixes
    on Jun 25, 2026
  4. added 2 commits that reference this issue on Jun 26, 2026
  5. corona10 commented on Jun 26, 2026

    @corona10
    MemberAuthor

    More stuff still left, I am working on it.

  6. added 12 commits that reference this issue on Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

3.14bugs and security fixes3.15bugs and security fixes3.16new features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)topic-free-threading

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions