Skip to content

Commit 1a9dc14

Browse files
committed
Concurrency runtime: Fix location of tsan_release edges for actors.
The TSAN release edge should appear before the actual cmpxchg-release.
1 parent d7e0971 commit 1a9dc14

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

stdlib/public/Concurrency/Actor.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,7 @@ void DefaultActorImpl::giveUpThread(RunningJobInfo runner) {
890890
auto firstNewJob = preprocessQueue(oldState.FirstJob, JobRef(), nullptr,
891891
overridesToWake);
892892

893+
_swift_tsan_release(this);
893894
while (true) {
894895
State newState = oldState;
895896
newState.FirstJob = JobRef::getPreprocessed(firstNewJob);
@@ -929,7 +930,6 @@ void DefaultActorImpl::giveUpThread(RunningJobInfo runner) {
929930
// Try again.
930931
continue;
931932
}
932-
_swift_tsan_release(this);
933933

934934
#if SWIFT_TASK_PRINTF_DEBUG
935935
# define LOG_STATE_TRANSITION fprintf(stderr, "%p transition from %zx to %zx in %p.%s\n", \
@@ -1069,6 +1069,7 @@ Job *DefaultActorImpl::claimNextJobOrGiveUp(bool actorIsOwned,
10691069
nullptr, overridesToWake);
10701070

10711071
Optional<JobPriority> remainingJobPriority;
1072+
_swift_tsan_release(this);
10721073
while (true) {
10731074
State newState = oldState;
10741075

@@ -1112,11 +1113,6 @@ Job *DefaultActorImpl::claimNextJobOrGiveUp(bool actorIsOwned,
11121113
}
11131114
LOG_STATE_TRANSITION;
11141115

1115-
if (jobToRun)
1116-
_swift_tsan_acquire(this);
1117-
else
1118-
_swift_tsan_release(this);
1119-
11201116
// We successfully updated the state.
11211117

11221118
// If we're giving up the thread with jobs remaining, we need

0 commit comments

Comments
 (0)