Skip to content

Commit 16da639

Browse files
author
Julian Lettner
committed
Move TSan release edge to swift_task_enqueueGlobal()
Move the TSan release edge from `swift_task_create_commonImpl()` to `swift_task_enqueueGlobalImpl()`. Task creation itself is not an event that needs synchronization, but rather that task creation "happens before" execution of that task on another thread. This edge is usually added when the task is scheduled via `swift_task_enqueue()` (which then usually calls `swift_task_enqueueGlobal()`). However, not all task scheduling goes through the `swift_task_enqueue()` funnel as some places call the more specific `swift_task_enqueueGlobal()` directly. So let's annotate this function (duplicate edges aren't harmful) to ensure we cover all schedule events, including newly-created tasks (our original problem here). rdar://78932849 (cherry picked from commit e4e941e)
1 parent 4180b98 commit 16da639

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

stdlib/public/Concurrency/GlobalExecutor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ static void swift_task_enqueueGlobalImpl(Job *job) {
335335
}
336336

337337
void swift::swift_task_enqueueGlobal(Job *job) {
338+
_swift_tsan_release(job);
339+
338340
if (swift_task_enqueueGlobal_hook)
339341
swift_task_enqueueGlobal_hook(job, swift_task_enqueueGlobalImpl);
340342
else

0 commit comments

Comments
 (0)