Skip to content

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

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

Metadata

Metadata

Assignees

Labels

3.14bugs and security fixes3.15pre-release feature fixes, bugs and security fixes3.16new features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)topic-free-threading
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions