mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 616056 - prevent double registration of binary components, which causes crashes due to dead KnownModule pointers, r=Mossop a=blocking
This commit is contained in:
parent
ffc2c81be4
commit
6c167a9962
@ -144,6 +144,8 @@ endif
|
||||
# Testing frameworks support
|
||||
################################################################################
|
||||
|
||||
testxpcobjdir = $(DEPTH)/_tests/xpcshell
|
||||
|
||||
ifdef ENABLE_TESTS
|
||||
|
||||
ifdef XPCSHELL_TESTS
|
||||
@ -151,8 +153,6 @@ ifndef relativesrcdir
|
||||
$(error Must define relativesrcdir when defining XPCSHELL_TESTS.)
|
||||
endif
|
||||
|
||||
testxpcobjdir = $(DEPTH)/_tests/xpcshell
|
||||
|
||||
# Test file installation
|
||||
ifneq (,$(filter WINNT os2-emx,$(HOST_OS_ARCH)))
|
||||
# Windows and OS/2 nsinstall can't recursively copy directories, so use nsinstall.py
|
||||
|
@ -144,6 +144,8 @@ endif
|
||||
# Testing frameworks support
|
||||
################################################################################
|
||||
|
||||
testxpcobjdir = $(DEPTH)/_tests/xpcshell
|
||||
|
||||
ifdef ENABLE_TESTS
|
||||
|
||||
ifdef XPCSHELL_TESTS
|
||||
@ -151,8 +153,6 @@ ifndef relativesrcdir
|
||||
$(error Must define relativesrcdir when defining XPCSHELL_TESTS.)
|
||||
endif
|
||||
|
||||
testxpcobjdir = $(DEPTH)/_tests/xpcshell
|
||||
|
||||
# Test file installation
|
||||
ifneq (,$(filter WINNT os2-emx,$(HOST_OS_ARCH)))
|
||||
# Windows and OS/2 nsinstall can't recursively copy directories, so use nsinstall.py
|
||||
|
@ -442,6 +442,9 @@ nsComponentManagerImpl::RegisterModule(const mozilla::Module* aModule,
|
||||
KnownModule* m = new KnownModule(aModule, aFile);
|
||||
if (aFile) {
|
||||
nsCOMPtr<nsIHashable> h = do_QueryInterface(aFile);
|
||||
NS_ASSERTION(!mKnownFileModules.Get(h),
|
||||
"Must not register a binary module twice.");
|
||||
|
||||
mKnownFileModules.Put(h, m);
|
||||
}
|
||||
else
|
||||
@ -478,7 +481,7 @@ nsComponentManagerImpl::RegisterCIDEntry(const mozilla::Module::CIDEntry* aEntry
|
||||
|
||||
nsFactoryEntry* f = mFactories.Get(*aEntry->cid);
|
||||
if (f) {
|
||||
NS_ERROR("Re-registering a CID?");
|
||||
NS_WARNING("Re-registering a CID?");
|
||||
|
||||
char idstr[NSID_LENGTH];
|
||||
aEntry->cid->ToProvidedString(idstr);
|
||||
@ -734,6 +737,15 @@ nsComponentManagerImpl::ManifestBinaryComponent(ManifestProcessingContext& cx, i
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHashable> h = do_QueryInterface(clfile);
|
||||
NS_ASSERTION(h, "nsILocalFile doesn't implement nsIHashable");
|
||||
if (mKnownFileModules.Get(h)) {
|
||||
NS_WARNING("Attempting to register a binary component twice.");
|
||||
LogMessageWithContext(cx.mFile, cx.mPath, lineno,
|
||||
"Attempting to register a binary component twice.");
|
||||
return;
|
||||
}
|
||||
|
||||
const mozilla::Module* m = mNativeModuleLoader.LoadModule(clfile);
|
||||
if (!m)
|
||||
return;
|
||||
|
@ -49,7 +49,7 @@ ifndef MOZ_ENABLE_LIBXUL
|
||||
MOZILLA_INTERNAL_API = 1
|
||||
endif
|
||||
|
||||
DIRS = external
|
||||
DIRS = external component
|
||||
|
||||
# Disabled because manifests make this test difficult to run correctly.
|
||||
# ifdef MOZ_ENABLE_LIBXUL
|
||||
|
78
xpcom/tests/component/Makefile.in
Normal file
78
xpcom/tests/component/Makefile.in
Normal file
@ -0,0 +1,78 @@
|
||||
#
|
||||
# ***** 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
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Benjamin Smedberg <benjamin@smedbergs.us>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of 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 *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
LIBRARY_NAME = testcomponent
|
||||
IS_COMPONENT = 1
|
||||
CPPSRCS = TestComponent.cpp
|
||||
NO_DIST_INSTALL = 1
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
MANIFEST_FILE = testcomponent.manifest
|
||||
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \
|
||||
$(XPCOM_FROZEN_LDOPTS) \
|
||||
$(NSPR_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
# Need to link with CoreFoundation on Mac
|
||||
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
$(TK_LIBS) \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -DLIBRARY_FILENAME="$(SHARED_LIBRARY)"
|
||||
|
||||
unittestlocation = xpcom/tests/unit
|
||||
|
||||
libs:: $(SHARED_LIBRARY)
|
||||
$(INSTALL) $^ $(testxpcobjdir)/$(unittestlocation)
|
||||
|
||||
libs:: $(MANIFEST_FILE)
|
||||
$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $< > $(testxpcobjdir)/$(unittestlocation)/$(<F)
|
65
xpcom/tests/component/TestComponent.cpp
Normal file
65
xpcom/tests/component/TestComponent.cpp
Normal file
@ -0,0 +1,65 @@
|
||||
/* -*- 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
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Suresh Duddu <dp@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of 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 ***** */
|
||||
|
||||
#include "mozilla/ModuleUtils.h"
|
||||
|
||||
#define NS_TESTING_CID \
|
||||
{ 0x335fb596, 0xe52d, 0x418f, \
|
||||
{ 0xb0, 0x1c, 0x1b, 0xf1, 0x6c, 0xe5, 0xe7, 0xe4 } }
|
||||
|
||||
NS_DEFINE_NAMED_CID(NS_TESTING_CID);
|
||||
|
||||
static nsresult
|
||||
DummyConstructorFunc(nsISupports* aOuter, const nsIID& aIID, void** aResult)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static const mozilla::Module::CIDEntry kTestCIDs[] = {
|
||||
{ &kNS_TESTING_CID, false, NULL, DummyConstructorFunc },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static const mozilla::Module kTestModule = {
|
||||
mozilla::Module::kVersion,
|
||||
kTestCIDs
|
||||
};
|
||||
|
||||
NSMODULE_DEFN(dummy) = &kTestModule;
|
||||
|
||||
|
4
xpcom/tests/component/testcomponent.manifest
Normal file
4
xpcom/tests/component/testcomponent.manifest
Normal file
@ -0,0 +1,4 @@
|
||||
#filter substitution
|
||||
binary-component @LIBRARY_FILENAME@
|
||||
binary-component @LIBRARY_FILENAME@
|
||||
binary-component @LIBRARY_FILENAME@
|
@ -11,6 +11,8 @@ var gMessagesExpected = [
|
||||
{ line: 2, message: /Malformed CID/, found: false },
|
||||
{ line: 6, message: /re-register/, found: false },
|
||||
{ line: 9, message: /Could not/, found: false },
|
||||
{ line: 2, message: /binary component twice/, found: false },
|
||||
{ line: 3, message: /binary component twice/, found: false },
|
||||
];
|
||||
|
||||
const kConsoleListener = {
|
||||
@ -56,6 +58,8 @@ function run_test()
|
||||
var manifest = do_get_file('compmgr_warnings.manifest');
|
||||
Components.manager.QueryInterface(Ci.nsIComponentRegistrar).
|
||||
autoRegister(manifest);
|
||||
manifest = do_get_file('testcomponent.manifest');
|
||||
Components.manager.autoRegister(manifest);
|
||||
|
||||
run_deferred_event(function() {
|
||||
cs.unregisterListener(kConsoleListener);
|
||||
|
Loading…
Reference in New Issue
Block a user