gh-153297: Fix data race on assigning __name__ and __qualname__ to functions on FT builds#153335
gh-153297: Fix data race on assigning __name__ and __qualname__ to functions on FT builds#153335sobolevn wants to merge 6 commits into
__name__ and __qualname__ to functions on FT builds#153335Conversation
…e__` to functions on FT builds
|
I think there are places where these are read without critical section so it doesn't fix all the cases. |
|
Yes, like here :( // Objects/genobject.c
assert(func->func_name != NULL);
gen->gi_name = Py_NewRef(func->func_name);It now uses a critical section on But, |
|
This PR adds critical sections to import sys, threading, time
assert not sys._is_gil_enabled()
class M: pass
def target(): pass
target.__defaults__ = (M(),)
stop = False
def churn():
while not stop:
target.__defaults__ = (M(),)
def read():
while not stop:
d = target.__defaults__; del d
ts = [threading.Thread(target=churn) for _ in range(4)]
ts += [threading.Thread(target=read) for _ in range(8)]
for t in ts: t.start()
time.sleep(5); stop = True
for t in ts: t.join()Debug FT: ETA: Investigation and draft by Claude Code (Opus 4.8). |
func_set_qualnameunder free-threading #153297