From 636ce9e9a68873a2807b151b248f7a2e5751d912 Mon Sep 17 00:00:00 2001 From: Brendan Eich Date: Wed, 17 Nov 2010 13:05:50 -0800 Subject: [PATCH] Enable XPC_CHECK_WRAPPER_THREADSAFETY in release builds and make it force a failure from XPCWrappedNative::FinishInit (612745, r=gal). --- js/src/xpconnect/src/xpcprivate.h | 2 +- js/src/xpconnect/src/xpcwrappednative.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/js/src/xpconnect/src/xpcprivate.h b/js/src/xpconnect/src/xpcprivate.h index 7f334359abbc..fd3693604581 100644 --- a/js/src/xpconnect/src/xpcprivate.h +++ b/js/src/xpconnect/src/xpcprivate.h @@ -179,8 +179,8 @@ static FARPROC GetProcAddressA(HMODULE hMod, wchar_t *procName); #ifdef DEBUG #define XPC_DETECT_LEADING_UPPERCASE_ACCESS_ERRORS -#define XPC_CHECK_WRAPPER_THREADSAFETY #endif +#define XPC_CHECK_WRAPPER_THREADSAFETY #if defined(DEBUG_xpc_hacker) #define XPC_DUMP_AT_SHUTDOWN diff --git a/js/src/xpconnect/src/xpcwrappednative.cpp b/js/src/xpconnect/src/xpcwrappednative.cpp index ac521e7bd369..8257dd6704bc 100644 --- a/js/src/xpconnect/src/xpcwrappednative.cpp +++ b/js/src/xpconnect/src/xpcwrappednative.cpp @@ -1202,8 +1202,11 @@ XPCWrappedNative::FinishInit(XPCCallContext &ccx) mThread = do_GetCurrentThread(); if(HasProto() && GetProto()->ClassIsMainThreadOnly() && !NS_IsMainThread()) + { DEBUG_ReportWrapperThreadSafetyError(ccx, "MainThread only wrapper created on the wrong thread", this); + return JS_FALSE; + } #endif // A hack for bug 517665, increase the probability for GC. @@ -1511,7 +1514,8 @@ XPCWrappedNative::ReparentWrapperIfFound(XPCCallContext& ccx, if (!XPCPerThreadData::IsMainThread(ccx) || (wrapper && wrapper->GetProto() && - !wrapper->GetProto()->ClassIsMainThreadOnly())) { + !wrapper->GetProto()->ClassIsMainThreadOnly())) + { return NS_ERROR_FAILURE; }