Skip to content

Need to defer GC tracking of array.array construction #153083

Closed

Description

@corona10

The same bug affects
array.array: construction GC-tracks the object before
it's filled, so another thread can reach the half-built object via
gc.get_objects() mid-construction and race with the fill.

I am working on this.

WARNING: ThreadSanitizer: data race (pid=86250)
SUMMARY: ThreadSanitizer: data race arraymodule.c:964 in array_length
WARNING: ThreadSanitizer: data race (pid=86250)
SUMMARY: ThreadSanitizer: data race arraymodule.c:515 in q_getitem
WARNING: ThreadSanitizer: data race (pid=86250)
SUMMARY: ThreadSanitizer: data race alloc.c:746 in _mi_heap_realloc_zero
WARNING: ThreadSanitizer: data race (pid=86250)
SUMMARY: ThreadSanitizer: data race arraymodule.c:195 in array_resize
WARNING: ThreadSanitizer: data race (pid=86250)
SUMMARY: ThreadSanitizer: data race arraymodule.c:515 in q_getitem
WARNING: ThreadSanitizer: data race (pid=86250)
SUMMARY: ThreadSanitizer: data race arraymodule.c:159 in array_resize
WARNING: ThreadSanitizer: data race (pid=86250)
SUMMARY: ThreadSanitizer: data race arraymodule.c:515 in q_getitem
WARNING: ThreadSanitizer: data race (pid=86250)
SUMMARY: ThreadSanitizer: data race alloc.c:746 in _mi_heap_realloc_zero
WARNING: ThreadSanitizer: data race (pid=86250)
SUMMARY: ThreadSanitizer: data race arraymodule.c:195 in array_resize
==86250==ERROR: ThreadSanitizer: SEGV on unknown address 0x000102000100 (pc 0x000103c83aec bp 0x00016efe9ff0 sp 0x00016efe9fb0 T4883198)
SUMMARY: ThreadSanitizer: SEGV obmalloc.c:298 in _PyMem_MiFree

Linked PRs

Activity

  1. self-assigned this
    on Jul 5, 2026
  2. added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    3.14bugs and security fixes
    3.15bugs and security fixes
    3.16new features, bugs and security fixes
    on Jul 5, 2026
  3. added 4 commits that reference this issue on Jul 8, 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-threadingtype-bugAn unexpected behavior, bug, or error

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions