mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 11:26:09 +00:00
Bug 1053999 - Be more conservative in recursion checks before brain transplants (r=bholley)
This commit is contained in:
parent
138c8c6eea
commit
d701ccf82e
@ -2424,8 +2424,9 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
bool thisChrome = IsChromeWindow();
|
||||
|
||||
// Check if we're near the stack limit before we get anywhere near the
|
||||
// transplanting code.
|
||||
JS_CHECK_RECURSION(cx, return NS_ERROR_FAILURE);
|
||||
// transplanting code. We use a conservative check since we'll use a little
|
||||
// more space before we actually hit the critical "can't fail" path.
|
||||
JS_CHECK_RECURSION_CONSERVATIVE(cx, return NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<WindowStateHolder> wsh = do_QueryInterface(aState);
|
||||
NS_ASSERTION(!aState || wsh, "What kind of weird state are you giving me here?");
|
||||
|
@ -1741,8 +1741,9 @@ ReparentWrapper(JSContext* aCx, JS::Handle<JSObject*> aObjArg)
|
||||
js::AssertSameCompartment(aCx, aObjArg);
|
||||
|
||||
// Check if we're near the stack limit before we get anywhere near the
|
||||
// transplanting code.
|
||||
JS_CHECK_RECURSION(aCx, return NS_ERROR_FAILURE);
|
||||
// transplanting code. We use a conservative check since we'll use a little
|
||||
// more space before we actually hit the critical "can't fail" path.
|
||||
JS_CHECK_RECURSION_CONSERVATIVE(aCx, return NS_ERROR_FAILURE);
|
||||
|
||||
JS::Rooted<JSObject*> aObj(aCx, aObjArg);
|
||||
const DOMJSClass* domClass = GetDOMClass(aObj);
|
||||
|
@ -995,6 +995,7 @@ GetNativeStackLimit(JSContext *cx)
|
||||
* These macros report a stack overflow and run |onerror| if we are close to
|
||||
* using up the C stack. The JS_CHECK_CHROME_RECURSION variant gives us a little
|
||||
* extra space so that we can ensure that crucial code is able to run.
|
||||
* JS_CHECK_RECURSION_CONSERVATIVE gives us a little less space.
|
||||
*/
|
||||
|
||||
#define JS_CHECK_RECURSION(cx, onerror) \
|
||||
@ -1041,6 +1042,18 @@ GetNativeStackLimit(JSContext *cx)
|
||||
} \
|
||||
JS_END_MACRO
|
||||
|
||||
#define JS_CHECK_RECURSION_CONSERVATIVE(cx, onerror) \
|
||||
JS_BEGIN_MACRO \
|
||||
int stackDummy_; \
|
||||
if (!JS_CHECK_STACK_SIZE_WITH_TOLERANCE(js::GetNativeStackLimit(cx), \
|
||||
&stackDummy_, \
|
||||
-1024 * sizeof(size_t))) \
|
||||
{ \
|
||||
js_ReportOverRecursed(cx); \
|
||||
onerror; \
|
||||
} \
|
||||
JS_END_MACRO
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
StartPCCountProfiling(JSContext *cx);
|
||||
|
||||
|
@ -1073,9 +1073,10 @@ XPCWrappedNative::ReparentWrapperIfFound(XPCWrappedNativeScope* aOldScope,
|
||||
nsISupports* aCOMObj)
|
||||
{
|
||||
// Check if we're near the stack limit before we get anywhere near the
|
||||
// transplanting code.
|
||||
// transplanting code. We use a conservative check since we'll use a little
|
||||
// more space before we actually hit the critical "can't fail" path.
|
||||
AutoJSContext cx;
|
||||
JS_CHECK_RECURSION(cx, return NS_ERROR_FAILURE);
|
||||
JS_CHECK_RECURSION_CONSERVATIVE(cx, return NS_ERROR_FAILURE);
|
||||
|
||||
XPCNativeInterface* iface = XPCNativeInterface::GetISupports();
|
||||
if (!iface)
|
||||
|
Loading…
Reference in New Issue
Block a user