Skip to content

Data race in dk_nentries #153881

Description

@brijkapadia

Bug report

Bug description:

This is a sub-issue of #153852 with the gist here.


This reproducer crashes in free-threaded build with TSan:

importthreadingROUNDS=10000box= [None]
enter=threading.Barrier(2)
leave=threading.Barrier(2)
defreader():
for_inrange(ROUNDS):
enter.wait()
obj=box[0]
obj.__getstate__()
leave.wait()
defwriter():
foriinrange(ROUNDS):
box[0] =type(f"C{i}", (), {})()
enter.wait()
obj=box[0]
setattr(obj, f"{i}", 1)
leave.wait()
threads= [threading.Thread(target=reader), threading.Thread(target=writer)]
forthreadinthreads:
thread.start()
forthreadinthreads:
thread.join()

See the gist for more information.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions