brijkapadia · GitHub

Bug report

Bug description:

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


This reproducer crashes in free-threaded build with TSan:

import threading
ROUNDS = 10000
box = [None]
enter = threading.Barrier(2)
leave = threading.Barrier(2)
def reader():
    for _ in range(ROUNDS):
        enter.wait()
        obj = box[0]
        obj.__getstate__()
        leave.wait()
def writer():
    for i in range(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)]
for thread in threads:
    thread.start()
for thread in threads:
    thread.join()

See the gist for more information.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Read the original on github.com ↗