Closed Bug 981187 Opened 10 years ago Closed 8 years ago

Make the entire JS engine dontReportUncaught and handle exceptions in the embedding

Categories

(Core :: DOM: Core & HTML, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: bholley, Assigned: bholley)

References

(Depends on 1 open bug)

Details

Attachments

(2 obsolete files)

See bug 979926 comment 6. Basically, we should add a method on AutoEntryScript like .setPropagateUncaught(bool). We should probably make the default |false| here, so that we can assert against setting |true| when there's nothing else on the stack to propagate the exception to (i.e. when the previous entry is null/System).

When a AutoEntryScript comes off the stack, we check for a pending exception. If it exists, we either invoke an error reporter directly, or stick the exception on the previous JSContext. Then, we kill js_ReportUncaughtException. \o/

I don't think we can do this until we actually use the Script Settings Stack everywhere (instead of just pushing raw JSContexts), so this is blocked on bug 951991.

We'll need to do something different on Workers, but it should be relatively straightforward.
Blocks: 981188
Depends on: 981198
Blocks: 981201
Blocks: 981209
This is actually a bit of a pain to do with the current JSAPI.  The current APIs explicitly have "report" functions whose semantics are actually "report unless we're running script; then set a pending exception".  I would love it if we'd start by separating "set pending exception" APIs from "report" APIs.
It seems like part of this bug or a bug blocking this would be adding these new and improved SetPendingException JSAPIs.

I think you'd also need an enhanced version of JS_GetPendingException: when we create an error object, we also create a hidden JSErrorReport and attach this to the exception in a reserved slot.  The JSErrorReport is only used if the exception is uncaught and it contains a bit of extra info that you can't get from the exception object itself.  Thus, if you want to remove JS_ReportPendingException/js_ReportUncaughtException, you'd need this enhanced GetPendingException to provide the associated JSErrorReport (if it exists).
Blocks: 969760
Blocks: 987048
Blocks: 987222
Depends on: 989069
Blocks: 1044109
Attached patch implement_sane_error_api-v0.diff (obsolete) — Splinter Review
This patch introduces JS::ThrowException, JS::ReportWarning, and JS::ReportStrictWarning. Throw does SendPendingException and report calls the error reporter, modulo WERROR and strict error reporting options.

What is here is a good start, but it is not yet sufficient for what gecko (or the GC) need from it.

Most importantly, the distinction between JSErrorReport, ErrorObject, and ExceptionObject is pretty much totally bogus. I need to spend some "quality" time with our various reporter callbacks to find the right set of properties to expose and how. In particular, both reports and exceptions end up going through the report callback, so it seems silly to lazily create either the exception or the report, much less both. We generally end up creating at least 3 simultaneous copies of the error report string, sometimes more.

Off thread parsing: the current patch is capable of replacing PJS exceptions -- a nice simplification -- but it totally ignores off-thread-parsing errors. These will need attention before I get too much further.

Error args: I don't even. The only real user is gecko's own js.msg, which appears to have copied our own terrible ideas wholesale. This is a pretty high priority for me to kill off. The test that uses them is just insane and needs to die ingloriously.

Uncatchable exceptions: We currently represent these by JSEXN_NONE in the report and no pending exception. This means the API user has to have two error paths, when one should be sufficient.

There are probably other things I've yet to uncover as well. I expect there will be some semantic changes as we convert stuff to use the new algorithm, but I'm not terribly worried about this: our current API is too confusing to use correctly, and thus simply isn't in most places. In the hour or so I've spent using the new API to replace the old, the vast majority of the sites I've replaced have had something subtly wrong with them. We'll see how things pan out as we replace more.
Assignee: nobody → terrence
Status: NEW → ASSIGNED
Attachment #8484611 - Flags: feedback?(jwalden+bmo)
Attachment #8484611 - Flags: feedback?(jorendorff)
Attached patch replace_some_reporting-v0.diff (obsolete) — Splinter Review
Uses the new api to replace mostly warning sites.
Attachment #8484612 - Flags: feedback?(jwalden+bmo)
Attachment #8484612 - Flags: feedback?(jorendorff)
Comment on attachment 8484611 [details] [diff] [review]
implement_sane_error_api-v0.diff

At Bobby's request, I'm moving these to a JS-api specific bug.
Attachment #8484611 - Flags: feedback?(jwalden+bmo)
Attachment #8484611 - Flags: feedback?(jorendorff)
Attachment #8484612 - Attachment is obsolete: true
Attachment #8484612 - Flags: feedback?(jwalden+bmo)
Attachment #8484612 - Flags: feedback?(jorendorff)
Attachment #8484611 - Attachment is obsolete: true
Assignee: terrence → bobbyholley
Depends on: 1063241
Blocks: 1063241
No longer depends on: 1063241
Depends on: 1066244
Blocks: 1067574
Depends on: 1070049
No longer blocks: 1067574
Depends on: 1072144
Blocks: 1076677
Depends on: 1227190
Depends on: 1252565
Depends on: 1254393
Depends on: 1254847
Depends on: 1255181
Depends on: 1255817
This is done now (bug 1277278 removed dontReportUncaught).
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: