Closed Bug 1107777 Opened 10 years ago Closed 10 years ago

js::ReportError() should set exception on cx if embedder is going to handle it, even if script is not running.

Categories

(Core :: JavaScript Engine, defect)

36 Branch
x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla37

People

(Reporter: nsm, Assigned: nsm)

References

Details

Attachments

(1 file, 2 obsolete files)

ReportError() currently gates on JS_IsRunning() before setting the exception on the context. Otherwise it just reports the error. In cases where the embedder sets dontReportUncaught, this leads to it not being unable to handle the exception in cases where script doesn't run, but we use the JSAPI (JS_ParseJSON for example).
If JS is not running, the error reporting infrastructure just reports the
exception to the error reporter. This prevents the embedder from handling it
after setting dontReportUncaught since js_ErrorToException isn't called. This
patch sets the exception even if JS is not running if the embedder will handle
it.
Attachment #8532327 - Flags: review?(bobbyholley)
Assignee: nobody → nsm.nikhil
Status: NEW → ASSIGNED
Attachment #8532327 - Flags: review?(bobbyholley) → review+
Comment on attachment 8532327 [details] [diff] [review]
Try to set exception on JSContext if embedder will handle it

this patch is wrong and fails some tests.
Attachment #8532327 - Attachment is obsolete: true
Comment on attachment 8537348 [details] [diff] [review]
Add autoJSAPIOwnsErrorReporting flag to JSContext options. AutoJSAPI sets it

Review of attachment 8537348 [details] [diff] [review]:
-----------------------------------------------------------------

Look great! thanks for doing this.

::: js/src/jsapi.h
@@ +1640,4 @@
>    private:
>      bool privateIsNSISupports_ : 1;
>      bool dontReportUncaught_ : 1;
> +    bool autoJSAPIOwnsErrorReporting_ : 1;

Add a comment here explaining why we're doing this - dontReportUncaught is kind of random in Gecko at the moment, and we want a clear indicator that the embedding is going to take ownership of error reporting. Also note that this should eventually become the default and both options will go away.
Attachment #8537348 - Flags: review?(bobbyholley) → review+
https://hg.mozilla.org/mozilla-central/rev/7fe7d8036eac
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla37
I'm recently (last 1-2 nightlies) getting some crashes with the top third frame showing code that was added with this changeset in bug 1114079.

The crash happens in "js_ErrorToException(cx, message, reportp, callback, userRef)".

I'll set the bug blocking this one, please correct me if I'm wrong.
Depends on: 1114079
:nsm

It looks like this changeset caused bug 1114079. Please have a look at the comment above and the linked bug.
Flags: needinfo?(nsm.nikhil)
Flags: needinfo?(nsm.nikhil)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: