Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DinoV opened this issue Sep 24, 2024 · 0 comments
Closed
Assignees
Labels
topic-free-threading type-bug An unexpected behavior, bug, or error

Comments

@DinoV
Copy link
Contributor

DinoV commented Sep 24, 2024

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

@DinoV DinoV added type-bug An unexpected behavior, bug, or error topic-free-threading labels Sep 24, 2024
@DinoV DinoV self-assigned this Sep 24, 2024
DinoV added a commit that referenced this issue Nov 21, 2024
…le replacing it (#122489)

Delay free a dictionary when replacing it
ebonnal pushed a commit to ebonnal/cpython that referenced this issue Jan 12, 2025
…ry while replacing it (python#122489)

Delay free a dictionary when replacing it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-free-threading type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants