diff --git a/profiler/src/ProfilerEngine/Datadog.Profiler.Native/StackSamplerLoop.cpp b/profiler/src/ProfilerEngine/Datadog.Profiler.Native/StackSamplerLoop.cpp index 7f8697430de8..bf8e5d979f3d 100644 --- a/profiler/src/ProfilerEngine/Datadog.Profiler.Native/StackSamplerLoop.cpp +++ b/profiler/src/ProfilerEngine/Datadog.Profiler.Native/StackSamplerLoop.cpp @@ -122,11 +122,13 @@ bool StackSamplerLoop::StartImpl() bool StackSamplerLoop::StopImpl() { _shutdownRequested = true; + if (_pLoopThread != nullptr) { try { _pLoopThread->join(); + _pLoopThread.reset(); } catch (const std::exception&) {