Temporary mochitest debugging: eliminate race condition between parent exit and child minidump request.

This commit is contained in:
Chris Jones 2010-01-26 09:40:42 -08:00
Родитель 7e7f0841a8
Коммит b61694e1b1
2 изменённых файлов: 42 добавлений и 13 удалений

Просмотреть файл

@ -81,6 +81,22 @@ IsProcessDead(pid_t process)
return exited;
}
bool
WaitForProcessExitMaxSecs(pid_t process, int maxSecs)
{
bool infiniteWait = (maxSecs < 0);
int status;
int nWaits = 0;
do {
HANDLE_EINTR(waitpid(process, &status, WNOHANG));
} while (!WIFEXITED(status) &&
(infiniteWait || nWaits++ < maxSecs) &&
0 == HANDLE_EINTR(sleep(1)));
return WIFEXITED(status);
}
class ChildReaper : public base::MessagePumpLibevent::SignalEvent,
public base::MessagePumpLibevent::SignalWatcher
@ -126,20 +142,16 @@ protected:
HANDLE_EINTR(waitpid(process_, NULL, 0));
#else
const int maxWaits = 30;
int waits = 0;
while (!IsProcessDead(process_) && ++waits < maxWaits)
sleep(1);
if (WaitForProcessExitMaxSecs(process_, 30)) {
printf("TEST-UNEXPECTED-FAIL | process %d done busy-waiting on | child process %d exited normally\n", getpid(), process_);
return;
}
if (waits < maxWaits) {
printf("TEST-UNEXPECTED-FAIL | process %d done busy-waiting on | child process %d\n", getpid(), process_);
}
else {
printf("TEST-UNEXPECTED-FAIL | process %d wait on | child process %d timed out!\n", getpid(), process_);
// kill the child in such a way that breakpad is triggered
kill(process_, SIGSEGV);
HANDLE_EINTR(waitpid(process_, NULL, 0));
}
printf("TEST-UNEXPECTED-FAIL | process %d wait on | child process %d timed out!\n", getpid(), process_);
// kill the child in such a way that breakpad is triggered
kill(process_, SIGSEGV);
WaitForProcessExitMaxSecs(process_, -1); // wait "forever"
#endif

Просмотреть файл

@ -1048,6 +1048,15 @@ OnChildProcessDumpRequested(void* aContext,
pid = aClientInfo->pid_;
#endif
#ifdef XP_LINUX
printf("TEST-UNEXPECTED-FAIL | got minidump at | %s\n", aFilePath->c_str());
#endif
// Get an .extra file with the same base name as the .dmp file
nsCOMPtr<nsIFile> extraFile;
nsresult rv = lf->Clone(getter_AddRefs(extraFile));
@ -1068,6 +1077,14 @@ OnChildProcessDumpRequested(void* aContext,
// Now write out the annotations to it
nsCOMPtr<nsIFileOutputStream> stream =
do_CreateInstance("@mozilla.org/network/file-output-stream;1");
if (!stream)
return;
rv = stream->Init(extraFile, -1, 0600, 0);
if (NS_FAILED(rv))
return;