Closed
Bug 578734
Opened 15 years ago
Closed 15 years ago
SpiderMonkey JS_EvaluateUCScriptForPrincipals doesn't clear exceptions after compile error, needs to call LAST_FRAME_CHECKS
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
DUPLICATE
of bug 451732
People
(Reporter: gwurk, Unassigned)
Details
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.70 Safari/533.4
Build Identifier:
This page http://developer.mozilla.org/En/SpiderMonkey/JSAPI_User_Guide#Automatic_handling_of_uncaught_exceptions claims that JS_EvaluateScript should clear any pending exceptions before it returns. However, it doesn't clear the exception if it is caused by compilation errors (e.g., syntax errors).
In the implementation of JS_EvaluateUCScriptForPrincipals() in jsapi.c, you do:
script = js_CompileScript(cx, obj, principals, TCF_COMPILE_N_GO,
chars, length, NULL, filename, lineno);
if (!script)
return JS_FALSE;
ok = js_Execute(cx, obj, script, NULL, 0, rval);
LAST_FRAME_CHECKS(cx, ok);
JS_DestroyScript(cx, script);
return ok;
You need to do the LAST_FRAME_CHECKS if js_CompileScript() fails as well.
Reproducible: Always
Steps to Reproduce:
#include <assert.h>
#include "jsapi.h"
int main() {
JSRuntime* rt = JS_NewRuntime(10000);
JSContext* cx = JS_NewContext(rt, 8192);
JSObject* obj = JS_NewObject(cx, NULL, NULL, NULL);
jsval rval;
static const char script[] = "!@#$ syntax error";
JS_EvaluateScript(cx, obj, script, sizeof(script) - 1, "src", 0, &rval);
// JS_EvaluateScript should clear syntax error exceptions but doesn't:
assert(!JS_IsExceptionPending(cx));
// if you take out the assert, running another script that throws will
// also fail if you build SpiderMonkey with the DEBUG macro defined:
static const char script2[] = "throw 123;";
JS_EvaluateScript(cx, obj, script2, sizeof(script2) - 1, "src", 0, &rval);
JS_DestroyContext(cx);
JS_DestroyRuntime(rt);
return 0;
}
Comment 1•15 years ago
|
||
Couple of things here, 20-20 hindsight but I hope helpful for next time:
* Search all (open and closed) bugs, in this case for LAST_FRAME_CHECKS.
* Check the latest http://hg.mozilla.org/mozilla-central/js/src for fixes. For the bleeding edge, try http://hg.mozilla.org/tracemonkey/js/src.
/be
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•