Browse Source

Fix deadlock if plCrashHandler is not running

Only wait for the crash server to do its job if it's attached. Silent
failures are evil, but it's better than hanging forever.
Adam Johnson 13 years ago
parent
commit
389d3c1802
  1. 4
      Sources/Plasma/FeatureLib/pfCrashHandler/plCrashCli.cpp
  2. 5
      Sources/Plasma/FeatureLib/pfCrashHandler/plCrashSrv.cpp
  3. 1
      Sources/Plasma/FeatureLib/pfCrashHandler/plCrash_Private.h

4
Sources/Plasma/FeatureLib/pfCrashHandler/plCrashCli.cpp

@ -134,5 +134,7 @@ void plCrashCli::ReportCrash(PEXCEPTION_POINTERS e)
void plCrashCli::WaitForHandle() void plCrashCli::WaitForHandle()
{ {
fHandled->Wait(); // Don't deadlock... Only wait if the CrashSrv is attached
if (fLink && fLink->fSrvReady)
fHandled->Wait();
} }

5
Sources/Plasma/FeatureLib/pfCrashHandler/plCrashSrv.cpp

@ -108,10 +108,11 @@ void plCrashSrv::IHandleCrash()
void plCrashSrv::HandleCrash() void plCrashSrv::HandleCrash()
{ {
#ifdef HS_BUILD_FOR_WIN32
if (!fLink) if (!fLink)
FATAL("plCrashMemLink is nil!"); FATAL("plCrashMemLink is nil!");
fLink->fSrvReady = true; // mark us as ready to receive crashes
#ifdef HS_BUILD_FOR_WIN32
// In Win32 land we have to hackily handle the client process exiting, so we'll wait on both // In Win32 land we have to hackily handle the client process exiting, so we'll wait on both
// the crashed semaphore and the client process... // the crashed semaphore and the client process...
HANDLE hack[2] = { fLink->fClientProcess, fCrashed->GetHandle() }; HANDLE hack[2] = { fLink->fClientProcess, fCrashed->GetHandle() };
@ -119,8 +120,6 @@ void plCrashSrv::HandleCrash()
hsAssert(result != WAIT_FAILED, "WaitForMultipleObjects failed"); hsAssert(result != WAIT_FAILED, "WaitForMultipleObjects failed");
#else #else
fCrashed->Wait(); fCrashed->Wait();
if (!fLink)
FATAL("plCrashMemLink is nil!");
#endif #endif
if (fLink->fCrashed) if (fLink->fCrashed)
IHandleCrash(); IHandleCrash();

1
Sources/Plasma/FeatureLib/pfCrashHandler/plCrash_Private.h

@ -59,6 +59,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
struct plCrashMemLink struct plCrashMemLink
{ {
bool fCrashed; bool fCrashed;
bool fSrvReady;
#ifdef HS_BUILD_FOR_WIN32 #ifdef HS_BUILD_FOR_WIN32
HANDLE fClientProcess; HANDLE fClientProcess;
uint32_t fClientProcessID; uint32_t fClientProcessID;

Loading…
Cancel
Save