Skip to content

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

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

Activity

  1. self-assigned this
    on Sep 24, 2024
  2. added a commit that references this issue on Nov 21, 2024
  3. added a commit that references this issue on Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions