zmoon111 / google-breakpad

Automatically exported from code.google.com/p/google-breakpad
0 stars 0 forks source link

Windows out-of-process dump writing doesn't work #524

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Start the sample Crash Generation app on Windows.
2. Client -> Request Dump

What is the expected output? What do you see instead?
I expect it to successfully create a dump. It fails to create a dump and 
reports this error in its output.

The cause of this is how the server_alive mutex is handled when the client and 
server are created on the same process (as the example application is). This 
can be tracked down to the function 
CrashGenerationClient::SignalCrashEventAndWait(), with this snippet at the end:

  HANDLE wait_handles[kWaitEventCount] = {crash_generated_, server_alive_};

  DWORD result = WaitForMultipleObjects(kWaitEventCount,
                                        wait_handles,
                                        FALSE,
                                        kWaitForServerTimeoutMs);

  // Crash dump was successfully generated only if the server
  // signaled the crash generated event.
  return result == WAIT_OBJECT_0;

As the server_alive mutex is locked on the same thread, this will immediately 
return, never giving the dump a chance to be generated (the server will fail 
when trying to read memory that is no longer available).

My fix is to change that code to:

  while (true) {
    DWORD server_alive_result = WaitForSingleObject(server_alive_, kWaitForServerTimeoutMs);
    DWORD dump_result = WaitForSingleObject(crash_generated_, 50);

    // Crash dump was successfully generated only if the server
    // signaled the crash generated event.
    if (dump_result == WAIT_OBJECT_0)
      return true;

    // If the server isn't alive, no need trying again
    if (server_alive_result != WAIT_OBJECT_0)
      return false;
  }

This has been tested and is working.

Original issue reported on code.google.com by d...@s2games.com on 5 Apr 2013 at 7:31