1. Matt Oswald
  2. xUnit++

Commits

Matt Oswald  committed 0ee6160

fixed a crash in the test runner due to the condition_variable getting destroyed by the parent thread exiting

  • Participants
  • Parent commits e2eb4d5
  • Branches default

Comments (0)

Files changed (1)

File xUnit++/TestRunner.cpp

View file
                     std::mutex m;
                     std::unique_lock<std::mutex> gate(m);
 
-                    std::condition_variable threadStarted;
-                    std::thread timedRunner([&]()
+                    auto threadStarted = std::make_shared<std::condition_variable>();
+                    std::thread timedRunner([&, threadStarted]()
                         {
                             m.lock();
                             m.unlock();
 
                             testStart = actualTest(false);
-                            threadStarted.notify_all();
+                            threadStarted->notify_all();
                         });
                     timedRunner.detach();
 
-                    if (threadStarted.wait_for(gate, testTimeLimit) == std::cv_status::timeout)
+                    if (threadStarted->wait_for(gate, testTimeLimit) == std::cv_status::timeout)
                     {
                         mImpl->OnTestFailure(test.testDetails, "Test failed to complete within " + std::to_string(testTimeLimit.count()) + " milliseconds.");
                         mImpl->OnTestFinish(test.testDetails, testTimeLimit);