Bug 1118996 - Wrap exception object in AutoNewContext r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Fri, 09 Jan 2015 09:56:18 +0000
changeset 250717 cdf0de7bbc4c997da2b77279daedbf8a9648efab
parent 250716 2c46028281ddcba1382a8aa7f5517ba2a2eb410b
child 250718 beacba1d431aee74abc7b20a826a911673e7691f
push id4610
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:32:55 +0000
treeherdermozilla-beta@4df54044d9ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1118996
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1118996 - Wrap exception object in AutoNewContext r=sfink
js/src/jit-test/tests/basic/bug1118996.js
js/src/shell/js.cpp
js/src/tests/lib/jittests.py
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/bug1118996.js
@@ -0,0 +1,13 @@
+// |jit-test| allow-oom; --fuzzing-safe; --no-threads; --no-ion
+g = newGlobal();
+gcparam('maxBytes', gcparam('gcBytes'));
+try {
+    evaluate("return 0", ({
+        global: g,
+        newContext: true
+    }));
+} catch (error) {
+    // We expect evaluate() above to fail with OOM, but due to GC zeal settings
+    // it may execute correctly and throw "SyntaxError: return not in function".
+    // This catch block is to ignore that error.
+}
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -986,17 +986,17 @@ class AutoNewContext
     ~AutoNewContext() {
         if (newcx) {
             RootedValue exc(oldcx);
             bool throwing = JS_IsExceptionPending(newcx);
             if (throwing)
                 JS_GetPendingException(newcx, &exc);
             newCompartment.reset();
             newRequest.reset();
-            if (throwing)
+            if (throwing && JS_WrapValue(oldcx, &exc))
                 JS_SetPendingException(oldcx, exc);
             DestroyContext(newcx, false);
         }
     }
 };
 
 static void
 my_LargeAllocFailCallback(void *data)
--- a/js/src/tests/lib/jittests.py
+++ b/js/src/tests/lib/jittests.py
@@ -434,17 +434,18 @@ def check_output(out, err, rc, timed_out
         # Tests which expect a timeout check for exit code 6.
         # Sometimes 0 is returned on Windows for unknown reasons.
         # See bug 899697.
         if sys.platform in ['win32', 'cygwin'] and rc == 0:
             return True
 
         # Allow a non-zero exit code if we want to allow OOM, but only if we
         # actually got OOM.
-        if test.allow_oom and 'out of memory' in err and 'Assertion failure' not in err:
+        if test.allow_oom and 'out of memory' in err \
+           and 'Assertion failure' not in err and 'MOZ_CRASH' not in err:
             return True
 
         # Allow a non-zero exit code if we want to allow unhandlable OOM, but
         # only if we actually got unhandlable OOM.
         if test.allow_unhandlable_oom and 'Assertion failure: [unhandlable oom]' in err:
             return True
 
         # Allow a non-zero exit code if we want to all too-much-recursion and