I have this function, try to ignore the types of parameters and variables. I'm absolutely sure that the objects are still there (they are created on the same thread before calling this function).
void ClientLoadUnloadStressTestcase::RunMasterForScenarioOverTimeWithAllConnections(ConnectionsController* Controller, MasterIPC &MasterIpc){
// Signal clients that we are set-up
MasterIpc.SignalAllClients();
ComputeEndTimeForScenarioOverTime();
std::atomic_bool mustContinue = true;
std::thread t{ [&]() {
while (mustContinue)
RunNewConnectionsSet(Controller, m_connectionNumber, m_dataSize);
} };
// Wait for time to be elapsed and clients to finish filtering.
MasterIpc.WaitForAllClients(TIME_TO_WAIT_FOR_TESTCASE_PROCESSES_TO_FINISH);
mustContinue = false;
t.join();
// Signal clients that connections are finished
MasterIpc.SignalAllClients();
}
Now, the problem is that once in a while, on some builds, the generated program will crash on the newly created thread, right here:
std::thread t{ [&]() {
while (mustContinue)
RunNewConnectionsSet(Controller, m_connectionNumber, m_dataSize);
} };
This is the callstack when the crash happened (I stripped out the arguments and other unnecessary information):
vrfcore!VerifierStopMessageEx+0x6d0
vfbasics!AVrfpCheckFirstChanceException+0xa2
vfbasics!AVrfpVectoredExceptionHandler+0x1a
ntdll!RtlpCallVectoredHandlers+0xe6
ntdll!RtlDispatchException+0x63
ntdll!KiUserExceptionDispatch+0x3a (TrapFrame @ 00000001`4617f9e8)
0x00000001`43a25f50
dci_tester!std::_Invoker_functor::_Call+0x6
dci_tester!std::invoke+0x6 (Inline Function @ 00007ff6`2fa1b6cf)
dci_tester!std::_LaunchPad<std::unique_ptr<std::tuple<void (__cdecl*)(void *),void *>,std::default_delete<std::tuple<void (__cdecl*)(void *),void *> > > >::_Execute+0x6
dci_tester!std::_LaunchPad<std::unique_ptr<std::tuple<void (__cdecl*)(void * __ptr64),void * __ptr64>,std::default_delete<std::tuple<void (__cdecl*)(void * __ptr64),void * __ptr64> > > >::_Run+0x6f
dci_tester!std::_LaunchPad<std::unique_ptr<std::tuple<void (__cdecl*)(void *),void *>,std::default_delete<std::tuple<void (__cdecl*)(void *),void *> > > >::_Go+0x5
dci_tester!std::_Pad::_Call_func+0x9
dci_tester!invoke_thread_procedure+0xe (Inline Function @ 00007ff6`2fbcd91d)
dci_tester!thread_start<unsigned int (__cdecl*)(void * __ptr64)>+0x5d
vfbasics!AVrfpStandardThreadFunction+0x4d
KERNEL32!BaseThreadInitThunk+0x22
ntdll!RtlUserThreadStart+0x34
That address that you see on the stack 0x00000001'43a25f50
is actually the address of the MyObject (this)
that is passed to the lambda function (because it is using it to run MyObject::RunNewConnectionsSet
method).
This crash happens only on some builds, but the executable will always crash on that line. We had the issue from thread several times before, but now I really wanna find an answer. Please help :).
Visual Studio 2015 version 14.0.24720.41
UPDATE (added the main thread call-stack)
ntdll!NtWaitForSingleObject+0x14
KERNELBASE!WaitForSingleObjectEx+0x9f
dci_tester!cppdex::WindowsSyncEvent::WaitForSignal+0x2e
dci_tester!cppdex::testing::IpcDispatcher::WaitForSignalFromProcess+0x25
dci_tester!MasterIPC::WaitForAllClients+0x4d
dci_tester!dci_tester::testcases::ClientLoadUnloadStressTestcase::RunMasterForScenarioOverTimeWithAllConnections+0xa2
dci_tester!dci_tester::testcases::ClientLoadUnloadStressTestcase::ConnectionsMasterProcessRoutine+0x1d1
dci_tester!dci_tester::testcases::DciMultiProcessTestcase::ProcessRoutine+0x1c1
dci_tester!cppdex::testing::MultiProcessTestcase::Run+0x6b
dci_tester!cppdex::testing::TestcaseManager<cppdex::testing::TestcaseDefaultCommandParser>::RunTestcase+0x175
dci_tester!ExecutableMain+0x64a
dci_tester!wmain+0x68
dci_tester!invoke_main+0x22
dci_tester!__scrt_common_main_seh+0x11d
kernel32!BaseThreadInitThunk+0x14
ntdll!RtlUserThreadStart+0x21
User contributions licensed under CC BY-SA 3.0