Bug 589495 - Win32 native exceptions (which could be crashes) on WoW64 are not fatal; r=bsmedberg a=blocking-betaN

This commit is contained in:
Ehsan Akhgari 2011-02-11 20:56:11 -05:00
Родитель c2f3d0be07
Коммит f58fafaaaa
9 изменённых файлов: 181 добавлений и 22 удалений

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

@ -78,6 +78,10 @@ using namespace mozilla::plugins;
#include "nsWindowsDllInterceptor.h"
#ifdef _MSC_VER
#include "nsCrashOnException.h"
#endif
typedef BOOL (WINAPI *User32TrackPopupMenu)(HMENU hMenu,
UINT uFlags,
int x,
@ -1140,6 +1144,20 @@ PluginInstanceChild::PluginWindowProc(HWND hWnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
#ifdef _MSC_VER
return mozilla::CallWindowProcCrashProtected(PluginWindowProcInternal, hWnd, message, wParam, lParam);
#else
return PluginWindowProcInternal(hWnd, message, wParam, lParam);
#endif
}
// static
LRESULT CALLBACK
PluginInstanceChild::PluginWindowProcInternal(HWND hWnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
NS_ASSERTION(!mozilla::ipc::SyncChannel::IsPumpingMessages(),
"Failed to prevent a nonqueued message from running!");

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

@ -78,6 +78,10 @@ class PluginInstanceChild : public PPluginInstanceChild
UINT message,
WPARAM wParam,
LPARAM lParam);
static LRESULT CALLBACK PluginWindowProcInternal(HWND hWnd,
UINT message,
WPARAM wParam,
LPARAM lParam);
#endif
protected:

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

@ -102,6 +102,10 @@ endif
endif
endif
LOCAL_INCLUDES = \
-I$(topsrcdir)/xpcom/base/ \
$(NULL)
ifneq (,$(filter WINNT Darwin,$(OS_ARCH)))
EXTRA_DSO_LIBS += gkgfx
endif

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

@ -59,6 +59,10 @@
#include "nsAutoPtr.h"
#include "nsTWeakRef.h"
#ifdef _MSC_VER
#include "nsCrashOnException.h"
#endif
#define NP_POPUP_API_VERSION 16
#define nsMajorVersion(v) (((PRInt32)(v) >> 16) & 0xffff)
@ -224,7 +228,7 @@ NS_IMETHODIMP nsDelayedPopupsEnabledEvent::Run()
/**
* New plugin window procedure
*/
static LRESULT CALLBACK PluginWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
static LRESULT CALLBACK PluginWndProcInternal(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
nsPluginNativeWindowWin * win = (nsPluginNativeWindowWin *)::GetProp(hWnd, NS_PLUGIN_WINDOW_PROPERTY_ASSOCIATION);
if (!win)
@ -382,6 +386,15 @@ static LRESULT CALLBACK PluginWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
return res;
}
static LRESULT CALLBACK PluginWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
#ifdef _MSC_VER
return mozilla::CallWindowProcCrashProtected(PluginWndProcInternal, hWnd, msg, wParam, lParam);
#else
return PluginWndProcInternal(hWnd, msg, wParam, lParam);
#endif
}
/*
* Flash will reset the subclass of our widget at various times.
* (Notably when entering and exiting full screen mode.) This

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

@ -132,6 +132,7 @@ LOCAL_INCLUDES = \
-I$(srcdir)/../xpwidgets \
-I$(srcdir) \
-I$(topsrcdir)/toolkit/xre \
-I$(topsrcdir)/xpcom/base \
$(NULL)
FORCE_STATIC_LIB = 1

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

@ -229,8 +229,8 @@
#include "mozilla/FunctionTimer.h"
#ifdef MOZ_CRASHREPORTER
#include "nsICrashReporter.h"
#ifdef _MSC_VER
#include "nsCrashOnException.h"
#endif
#include "nsIXULRuntime.h"
@ -4475,19 +4475,6 @@ nsWindow::IPCWindowProcHandler(UINT& msg, WPARAM& wParam, LPARAM& lParam)
*
**************************************************************/
#ifdef _MSC_VER
static int ReportException(EXCEPTION_POINTERS *aExceptionInfo)
{
#ifdef MOZ_CRASHREPORTER
nsCOMPtr<nsICrashReporter> cr =
do_GetService("@mozilla.org/toolkit/crash-reporter;1");
if (cr)
cr->WriteMinidumpForException(aExceptionInfo);
#endif
return EXCEPTION_EXECUTE_HANDLER;
}
#endif
static PRBool
DisplaySystemMenu(HWND hWnd, nsSizeMode sizeMode, PRBool isRtl, PRInt32 x, PRInt32 y)
{
@ -4531,12 +4518,7 @@ DisplaySystemMenu(HWND hWnd, nsSizeMode sizeMode, PRBool isRtl, PRInt32 x, PRInt
LRESULT CALLBACK nsWindow::WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
#ifdef _MSC_VER
__try {
return WindowProcInternal(hWnd, msg, wParam, lParam);
}
__except(ReportException(GetExceptionInformation())) {
::TerminateProcess(::GetCurrentProcess(), 253);
}
return mozilla::CallWindowProcCrashProtected(WindowProcInternal, hWnd, msg, wParam, lParam);
#else
return WindowProcInternal(hWnd, msg, wParam, lParam);
#endif

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

@ -98,6 +98,7 @@ EXPORTS_mozilla = \
ifeq (windows,$(MOZ_WIDGET_TOOLKIT))
CPPSRCS += nsSetDllDirectory.cpp
CPPSRCS += nsCrashOnException.cpp
endif
ifeq ($(OS_ARCH),WINNT)

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

@ -0,0 +1,78 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ehsan Akhgari <ehsan@mozilla.com> (Original Author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef _MSC_VER
#error This file only makes sense on Windows.
#endif
#include "nsCrashOnException.h"
#include "nsCOMPtr.h"
#include "nsServiceManagerUtils.h"
#ifdef MOZ_CRASHREPORTER
#include "nsICrashReporter.h"
#endif
namespace mozilla {
static int ReportException(EXCEPTION_POINTERS *aExceptionInfo)
{
#ifdef MOZ_CRASHREPORTER
nsCOMPtr<nsICrashReporter> cr =
do_GetService("@mozilla.org/toolkit/crash-reporter;1");
if (cr)
cr->WriteMinidumpForException(aExceptionInfo);
#endif
return EXCEPTION_EXECUTE_HANDLER;
}
XPCOM_API(LRESULT)
CallWindowProcCrashProtected(WNDPROC wndProc, HWND hWnd, UINT msg,
WPARAM wParam, LPARAM lParam)
{
__try {
return wndProc(hWnd, msg, wParam, lParam);
}
__except(ReportException(GetExceptionInformation())) {
::TerminateProcess(::GetCurrentProcess(), 253);
}
return 0; // not reached
}
}

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

@ -0,0 +1,58 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ehsan Akhgari <ehsan@mozilla.com> (Original Author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsCrashOnException_h
#define nsCrashOnException_h
#ifndef _MSC_VER
#error This file only makes sense on Windows with Visual C++.
#endif
#include <nscore.h>
#include <windows.h>
namespace mozilla {
// Call a given window procedure, and catch any Win32 exceptions raised from it,
// and report them as crashes.
XPCOM_API(LRESULT) CallWindowProcCrashProtected(WNDPROC wndProc, HWND hWnd, UINT msg,
WPARAM wParam, LPARAM lParam);
}
#endif