Bug 1331064 - Ignore wasm onExceptionUnwind events in JSTRAP_ERROR state. r=luke
authorYury Delendik <ydelendik@mozilla.com>
Wed, 18 Jan 2017 14:53:33 -0600
changeset 377585 49e6eba10d32047af1d645228419f820e96e3cde
parent 377584 10e2e2b01b66cc98c97f5616f3ff7cef98bf1bb1
child 377586 ed9c070f9bb47121a7adb11b306667283c45ad65
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1331064
milestone53.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 1331064 - Ignore wasm onExceptionUnwind events in JSTRAP_ERROR state. r=luke MozReview-Commit-ID: BU8YzfFLqc1
js/src/jit-test/tests/debug/bug1331064.js
js/src/wasm/WasmTypes.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/debug/bug1331064.js
@@ -0,0 +1,22 @@
+// |jit-test| test-also-wasm-baseline; exitstatus: 3
+
+load(libdir + "asserts.js");
+
+if (!wasmIsSupported())
+     quit(3);
+
+var g = newGlobal();
+g.parent = this;
+g.eval("new Debugger(parent).onExceptionUnwind = function () {  some_error; };");
+
+var module = new WebAssembly.Module(wasmTextToBinary(`
+(module
+    (import $imp "a" "b" (result i32))
+    (func $call (result i32) (call 0))
+    (export "call" $call)
+)`));
+
+var instance = new WebAssembly.Instance(module, { a: { b: () => {
+  some_other_error;
+}}});
+instance.exports.call();
--- a/js/src/wasm/WasmTypes.cpp
+++ b/js/src/wasm/WasmTypes.cpp
@@ -146,22 +146,26 @@ WasmHandleThrow()
     JSContext* cx = activation->cx();
 
     for (FrameIterator iter(activation, FrameIterator::Unwind::True); !iter.done(); ++iter) {
         if (!iter.debugEnabled())
             continue;
 
         DebugFrame* frame = iter.debugFrame();
 
-        JSTrapStatus status = Debugger::onExceptionUnwind(cx, frame);
-        if (status == JSTRAP_RETURN) {
-            // Unexpected trap return -- raising error since throw recovery
-            // is not yet implemented in the wasm baseline.
-            // TODO properly handle JSTRAP_RETURN and resume wasm execution.
-            JS_ReportErrorASCII(cx, "Unexpected resumption value from onExceptionUnwind");
+        // Assume JSTRAP_ERROR status if no exception is pending --
+        // no onExceptionUnwind handlers must be fired.
+        if (cx->isExceptionPending()) {
+            JSTrapStatus status = Debugger::onExceptionUnwind(cx, frame);
+            if (status == JSTRAP_RETURN) {
+                // Unexpected trap return -- raising error since throw recovery
+                // is not yet implemented in the wasm baseline.
+                // TODO properly handle JSTRAP_RETURN and resume wasm execution.
+                JS_ReportErrorASCII(cx, "Unexpected resumption value from onExceptionUnwind");
+            }
         }
 
         bool ok = Debugger::onLeaveFrame(cx, frame, nullptr, false);
         if (ok) {
             // Unexpected success from the handler onLeaveFrame -- raising error
             // since throw recovery is not yet implemented in the wasm baseline.
             // TODO properly handle success and resume wasm execution.
             JS_ReportErrorASCII(cx, "Unexpected success from onLeaveFrame");