Skip to content

Commit 75d0019

Browse files
swalrus1ydbot
authored andcommitted
fix thread sanitizer error in TActorSystem::IsStopped (#25149)
1 parent 2a83935 commit 75d0019

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

ydb/library/actors/core/actorsystem.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,7 @@ namespace NActors {
372372

373373
void TActorSystem::Start() {
374374
ACTORLIB_DEBUG(EDebugLevel::ActorSystem, "TActorSystem::Start");
375-
Y_ABORT_UNLESS(StartExecuted == false);
376-
StartExecuted = true;
375+
Y_ABORT_UNLESS(!StartExecuted.exchange(true));
377376

378377
ScheduleQueue.Reset(new NSchedulerQueue::TQueueType());
379378
TVector<NSchedulerQueue::TReader*> scheduleReaders;
@@ -418,13 +417,11 @@ namespace NActors {
418417

419418
void TActorSystem::Stop() {
420419
ACTORLIB_DEBUG(EDebugLevel::ActorSystem, "TActorSystem::Stop");
421-
if (StopExecuted || !StartExecuted) {
420+
if (!StartExecuted.load() || StopExecuted.exchange(true)) {
422421
ACTORLIB_DEBUG(EDebugLevel::ActorSystem, "TActorSystem::Stop: already stopped");
423422
return;
424423
}
425424

426-
StopExecuted = true;
427-
428425
for (auto&& fn : std::exchange(DeferredPreStop, {})) {
429426
fn();
430427
}
@@ -439,11 +436,10 @@ namespace NActors {
439436
void TActorSystem::Cleanup() {
440437
ACTORLIB_DEBUG(EDebugLevel::ActorSystem, "TActorSystem::Cleanup");
441438
Stop();
442-
if (CleanupExecuted || !StartExecuted) {
439+
if (!StartExecuted.load() || CleanupExecuted.exchange(true)) {
443440
ACTORLIB_DEBUG(EDebugLevel::ActorSystem, "TActorSystem::Cleanup: already cleaned up");
444441
return;
445442
}
446-
CleanupExecuted = true;
447443
CpuManager->Cleanup();
448444
Scheduler.Destroy();
449445
ACTORLIB_DEBUG(EDebugLevel::ActorSystem, "TActorSystem::Cleanup: cleaned up");

ydb/library/actors/core/actorsystem.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ namespace NActors {
162162
TMutex ProxyCreationLock;
163163
mutable std::vector<TActorId> DynamicProxies;
164164

165-
bool StartExecuted = false;
166-
bool StopExecuted = false;
167-
bool CleanupExecuted = false;
165+
std::atomic_bool StartExecuted = false;
166+
std::atomic_bool StopExecuted = false;
167+
std::atomic_bool CleanupExecuted = false;
168168

169169
std::deque<std::function<void()>> DeferredPreStop;
170170
public:

0 commit comments

Comments
 (0)