Bug 877378 - Fix shell-only compartment mismatch with evaluate and saveFrameChain. r=luke
authorJan de Mooij <jdemooij@mozilla.com>
Mon, 10 Jun 2013 16:43:03 +0200
changeset 146011 1c4403cbda5732fb4f18be1ea28059ea23e5617c
parent 146010 21800605ea673bfb355020c43b81a284a44ab9c4
child 146012 2ece779610559fb425fe221e3efbc1cf6ffdb79c
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs877378
milestone24.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 877378 - Fix shell-only compartment mismatch with evaluate and saveFrameChain. r=luke
js/src/jit-test/tests/basic/bug877378.js
js/src/shell/js.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/bug877378.js
@@ -0,0 +1,19 @@
+evalcx("\
+    let z = 'x';\
+    for (var v of z) {\
+        y = evaluate(\"Object.defineProperty(this,\\\"y\\\",\
+                         {get:  function() {}}\
+                    );\",\
+               {catchTermination: true, saveFrameChain: true}\
+        );\
+    }",
+    newGlobal('')
+)
+
+evalcx("\
+    for (x = 0; x < 1; ++x) { \
+        v = evaluate(\"gc\",{ \
+            saveFrameChain: true \
+        })\
+    }\
+", newGlobal(''));
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -1034,21 +1034,21 @@ Evaluate(JSContext *cx, unsigned argc, j
 
     AutoNewContext ancx;
     if (newContext) {
         if (!ancx.enter(cx))
             return false;
         cx = ancx.get();
     }
 
-    AutoSaveFrameChain asfc(cx);
-    if (saveFrameChain && !asfc.save())
-        return false;
-
     {
+        AutoSaveFrameChain asfc(cx);
+        if (saveFrameChain && !asfc.save())
+            return false;
+
         JSAutoCompartment ac(cx, global);
         uint32_t oldopts = JS_GetOptions(cx);
         uint32_t opts = oldopts & ~(JSOPTION_COMPILE_N_GO | JSOPTION_NO_SCRIPT_RVAL);
         if (compileAndGo)
             opts |= JSOPTION_COMPILE_N_GO;
         if (noScriptRval)
             opts |= JSOPTION_NO_SCRIPT_RVAL;