Closed Bug 1054335 Opened 10 years ago Closed 2 years ago

Shutdown deadlock with profiler in RemoveActiveSampler

Categories

(Core :: Gecko Profiler, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: mstange, Unassigned)

References

(Blocks 1 open bug)

Details

I've just hit this in a local build which won't shut down because the main thread is blocked in SamplerThread::RemoveActiveSampler. It's waiting for the sampler thread to join, on the line instance_->Join(); below. Unfortunately, RemoveActiveSampler holds the sRegisteredThreadMutex:

  static void RemoveActiveSampler(Sampler* sampler) {
    mozilla::MutexAutoLock lock(*Sampler::sRegisteredThreadsMutex);
    instance_->Join();

But the sampler thread is currently blocking on this mutex:

  virtual void Run() {
    while (SamplerRegistry::sampler->IsActive()) {
      if (!SamplerRegistry::sampler->IsPaused()) {
        mozilla::MutexAutoLock lock(*Sampler::sRegisteredThreadsMutex); // <--
        std::vector<ThreadInfo*> threads =
          SamplerRegistry::sampler->GetRegisteredThreads();
        bool isFirstProfiledThread = true;

And can't finish.
Blocks: 1329181

Thread registration has changed a lot since then.
And I've verified that the SamplerThread's thread is only joined when no locks are held, so this deadlock should not happen.
So I'll call this bug fixed.

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.