Bug 828034 - Fix crash when PluginModuleParent::CleanupFromTimeout runs before channel error notification. r=bsmedberg

This commit is contained in:
Aaron Klotz 2013-01-24 21:10:02 -05:00
parent 3d06005920
commit 494dd6c49d
2 changed files with 24 additions and 11 deletions

View File

@ -262,7 +262,7 @@ PluginModuleParent::TimeoutChanged(const char* aPref, void* aModule)
}
void
PluginModuleParent::CleanupFromTimeout()
PluginModuleParent::CleanupFromTimeout(const bool aFromHangUI)
{
if (mShutdown) {
return;
@ -273,11 +273,22 @@ PluginModuleParent::CleanupFromTimeout()
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
mTaskFactory.NewRunnableMethod(
&PluginModuleParent::CleanupFromTimeout), 10);
&PluginModuleParent::CleanupFromTimeout, aFromHangUI), 10);
return;
}
Close();
/* If the plugin container was terminated by the Plugin Hang UI,
then either the I/O thread detects a channel error, or the
main thread must set the error (whomever gets there first).
OTOH, if we terminate and return false from
ShouldContinueFromReplyTimeout, then the channel state has
already been set to ChannelTimeout and we should call the
regular Close function. */
if (aFromHangUI) {
GetIPCChannel()->CloseWithError();
} else {
Close();
}
}
#ifdef XP_WIN
@ -465,17 +476,19 @@ PluginModuleParent::TerminateChildProcess(MessageLoop* aMsgLoop)
// this must run before the error notification from the channel,
// or not at all
if (aMsgLoop == MessageLoop::current()) {
aMsgLoop->PostTask(
FROM_HERE,
mTaskFactory.NewRunnableMethod(
&PluginModuleParent::CleanupFromTimeout));
} else {
bool isFromHangUI = aMsgLoop != MessageLoop::current();
if (isFromHangUI) {
// If we're posting from a different thread we can't create
// the task via mTaskFactory
aMsgLoop->PostTask(FROM_HERE,
NewRunnableMethod(this,
&PluginModuleParent::CleanupFromTimeout));
&PluginModuleParent::CleanupFromTimeout,
isFromHangUI));
} else {
aMsgLoop->PostTask(
FROM_HERE,
mTaskFactory.NewRunnableMethod(
&PluginModuleParent::CleanupFromTimeout, isFromHangUI));
}
if (!KillProcess(OtherProcess(), 1, false))

View File

@ -296,7 +296,7 @@ private:
void ProcessFirstMinidump();
void WriteExtraDataForMinidump(CrashReporter::AnnotationTable& notes);
#endif
void CleanupFromTimeout();
void CleanupFromTimeout(const bool aByHangUI);
void SetChildTimeout(const int32_t aChildTimeout);
static int TimeoutChanged(const char* aPref, void* aModule);
void NotifyPluginCrashed();