Skip to content

Commit beb2907

Browse files
committed
Fix FTP build: return; in non-void function (caught by clang)
_PyGC_ParallelPropagateAliveWithPool returns int but the reentrant-skip path used "return;" (no value). GCC accepted this silently with the return value undefined; clang (TSan build) rejects it as an error. The function is called only from FTP STW collection paths. STW means no __del__-releases-GIL window that could re-enter dispatch — same logic as the other three sites (UpdateRefsWithPool, MarkHeapWithPool, ScanHeapWithPool) which already used the assert-not-reentrant pattern. Mirror that here. This unblocks the FTP+TSan build that needed for the post-NBS audit "TSan on the new FTP dispatch architecture" item. Verified: clang -fsanitize=thread + --disable-gil now builds clean. TSan run on FTP build: 90 tests pass, 0 data races, 0 DEADLYSIGNAL.
1 parent 9d03efb commit beb2907

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

Python/gc_free_threading_parallel.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,13 +2156,11 @@ _PyGC_ParallelPropagateAliveWithPool(PyInterpreterState *interp,
21562156
}
21572157

21582158
// Dispatch to adaptive_workers (mirror of GIL parallel GC).
2159-
// Helpers wake via per-worker condvars; main thread does worker 0's
2160-
// work inside _PyGC_FTDispatchAndWait and waits for the rest to signal.
2161-
if (_PyGC_FTDispatchAndWait(pool, pool->adaptive_workers)) {
2162-
// Reentrant dispatch — caller should treat as serial fallback.
2163-
pool->current_work = NULL;
2164-
return;
2165-
}
2159+
// FTP STW collections shouldn't release a lock that re-enters GC, so
2160+
// reentrant dispatch shouldn't happen — assert if it does.
2161+
int reentrant = _PyGC_FTDispatchAndWait(pool, pool->adaptive_workers);
2162+
assert(reentrant == 0 && "FTP STW dispatch should not be reentrant");
2163+
(void)reentrant;
21662164

21672165
// Clear work descriptor
21682166
pool->current_work = NULL;

0 commit comments

Comments
 (0)