15
15
#include " mozilla/ArrayUtils.h"
16
16
17
17
#include " nsCOMPtr.h"
18
+ #include " nsExceptionHandler.h"
18
19
#include " nsAutoPtr.h"
19
20
#include " nsMemory.h"
20
21
#include " nsProcess.h"
@@ -245,19 +246,7 @@ void nsProcess::Monitor(void* aArg) {
245
246
exitCode = -1 ;
246
247
}
247
248
}
248
-
249
- // Lock in case Kill or GetExitCode are called during this
250
- {
251
- MutexAutoLock lock (process->mLock );
252
- CloseHandle (process->mProcess );
253
- process->mProcess = nullptr ;
254
- process->mExitValue = exitCode;
255
- if (process->mShutdown ) {
256
- return ;
257
- }
258
- }
259
- #else
260
- #ifdef XP_UNIX
249
+ #elif defined(XP_UNIX)
261
250
int exitCode = -1 ;
262
251
int status = 0 ;
263
252
pid_t result;
@@ -278,9 +267,15 @@ void nsProcess::Monitor(void* aArg) {
278
267
}
279
268
#endif
280
269
270
+ // The application has finished executing once we reach this point
271
+ RemoveExecutableCrashAnnotation ();
272
+
281
273
// Lock in case Kill or GetExitCode are called during this
282
274
{
283
275
MutexAutoLock lock (process->mLock );
276
+ #if defined(PROCESSMODEL_WINAPI)
277
+ CloseHandle (process->mProcess );
278
+ #endif
284
279
#if !defined(XP_UNIX)
285
280
process->mProcess = nullptr ;
286
281
#endif
@@ -289,7 +284,6 @@ void nsProcess::Monitor(void* aArg) {
289
284
return ;
290
285
}
291
286
}
292
- #endif
293
287
294
288
// If we ran a background thread for the monitor then notify on the main
295
289
// thread
@@ -547,6 +541,8 @@ nsresult nsProcess::RunProcess(bool aBlocking, char** aMyArgv,
547
541
mPid = ptrProc->pid ;
548
542
#endif
549
543
544
+ AddExecutableCrashAnnotation ();
545
+
550
546
NS_ADDREF_THIS ();
551
547
mBlocking = aBlocking;
552
548
if (aBlocking) {
@@ -584,6 +580,32 @@ nsProcess::GetIsRunning(bool* aIsRunning) {
584
580
return NS_OK;
585
581
}
586
582
583
+ void nsProcess::AddExecutableCrashAnnotation () {
584
+ #if defined(XP_WIN)
585
+ nsAutoCString executableName;
586
+ if (NS_FAILED(mExecutable ->GetNativeLeafName (executableName))) {
587
+ return ;
588
+ }
589
+
590
+ // The following executables might be launched during shutdown and lead to a
591
+ // shutdown hang. We're adding this annotation to try and detect which is the
592
+ // culprit of bug 1386760
593
+ if (executableName.EqualsLiteral (" minidump-analyzer.exe" ) ||
594
+ executableName.EqualsLiteral (" pingsender.exe" ) ||
595
+ executableName.EqualsLiteral (" updater.exe" )) {
596
+ CrashReporter::AnnotateCrashReport (
597
+ CrashReporter::Annotation::ExecutableName, executableName.get ());
598
+ }
599
+ #endif // defined(XP_WIN)
600
+ }
601
+
602
+ /* static */ void nsProcess::RemoveExecutableCrashAnnotation () {
603
+ #if defined(XP_WIN)
604
+ CrashReporter::RemoveCrashReportAnnotation (
605
+ CrashReporter::Annotation::ExecutableName);
606
+ #endif // defined(XP_WIN)
607
+ }
608
+
587
609
NS_IMETHODIMP
588
610
nsProcess::GetStartHidden (bool * aStartHidden) {
589
611
*aStartHidden = mStartHidden ;
0 commit comments