Skip to content

Crash when assigning to instance dictionary from multiple threads while reading #124470

Closed
@DinoV

Description

@DinoV

Bug report

Bug description:

class C: pass

f = C()
# Reader code:
f.foo
# Writer code:
f.__dict__ = {}

When there's a thread reading from an object and another thread replacing the dictionary we can crash. This is because the read has a borrowed reference to the dictionary which gets simultaneously decref'd when the writer replaces it.

Expected behavior: No crashes

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions