mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Fixes crash in CrashReporter on child process shutdown, bug 548810. r=ted
This commit is contained in:
parent
55b7305f9e
commit
80dd558623
@ -1158,13 +1158,13 @@ static PLDHashOperator EnumerateChildAnnotations(const nsACString& key,
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
nsIFileOutputStream* extraStream =
|
||||
reinterpret_cast<nsIFileOutputStream*>(userData);
|
||||
PRUint32 written;
|
||||
extraStream->Write(key.BeginReading(), key.Length(), &written);
|
||||
extraStream->Write("=", 1, &written);
|
||||
extraStream->Write(entry.BeginReading(), entry.Length(), &written);
|
||||
extraStream->Write("\n", 1, &written);
|
||||
PRFileDesc* fd =
|
||||
reinterpret_cast<PRFileDesc*>(userData);
|
||||
|
||||
PR_Write(fd, key.BeginReading(), key.Length());
|
||||
PR_Write(fd, "=", 1);
|
||||
PR_Write(fd, entry.BeginReading(), entry.Length());
|
||||
PR_Write(fd, "\n", 1);
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
@ -1211,10 +1211,12 @@ OnChildProcessDumpRequested(void* aContext,
|
||||
#endif
|
||||
|
||||
// Get an .extra file with the same base name as the .dmp file
|
||||
nsCOMPtr<nsIFile> extraFile;
|
||||
nsresult rv = lf->Clone(getter_AddRefs(extraFile));
|
||||
nsCOMPtr<nsIFile> file;
|
||||
nsresult rv = lf->Clone(getter_AddRefs(file));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
nsCOMPtr<nsILocalFile> extraFile = do_QueryInterface(file);
|
||||
|
||||
nsAutoString leafName;
|
||||
rv = extraFile->GetLeafName(leafName);
|
||||
@ -1228,23 +1230,22 @@ OnChildProcessDumpRequested(void* aContext,
|
||||
return;
|
||||
|
||||
// Now write out the annotations to it
|
||||
nsCOMPtr<nsIFileOutputStream> stream =
|
||||
do_CreateInstance("@mozilla.org/network/file-output-stream;1");
|
||||
rv = stream->Init(extraFile, -1, 0600, 0);
|
||||
PRFileDesc* fd;
|
||||
rv = extraFile->OpenNSPRFileDesc(PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE,
|
||||
0600, &fd);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
crashReporterAPIData_Hash->EnumerateRead(EnumerateChildAnnotations,
|
||||
stream.get());
|
||||
fd);
|
||||
// Add CrashTime to extra data
|
||||
time_t crashTime = time(NULL);
|
||||
char crashTimeString[32];
|
||||
XP_TTOA(crashTime, crashTimeString, 10);
|
||||
|
||||
PRUint32 written;
|
||||
stream->Write(kCrashTimeParameter, kCrashTimeParameterLen, &written);
|
||||
stream->Write(crashTimeString, strlen(crashTimeString), &written);
|
||||
stream->Write("\n", 1, &written);
|
||||
stream->Close();
|
||||
PR_Write(fd, kCrashTimeParameter, kCrashTimeParameterLen);
|
||||
PR_Write(fd, crashTimeString, strlen(crashTimeString));
|
||||
PR_Write(fd, "\n", 1);
|
||||
PR_Close(fd);
|
||||
|
||||
bool doReport = true;
|
||||
char* e = getenv("MOZ_CRASHREPORTER_NO_REPORT");
|
||||
|
Loading…
Reference in New Issue
Block a user