Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: fix domains + --abort-on-uncaught-exception #922

Closed
wants to merge 7 commits into from
Closed

src: fix domains + --abort-on-uncaught-exception #922

wants to merge 7 commits into from

Conversation

chrisdickinson
Copy link
Contributor

If run with --abort-on-uncaught-exception, V8 will abort the process whenever it does not see a JS-installed CatchClause in the stack. C++ TryCatch clauses are ignored. Domains work by setting a FatalException handler which is ignored when running in abort mode.

This patch modifies MakeCallback to call its target function through a JS function that installs a CatchClause and manually calls _fatalException on error, if the process is both using domains and is in abort mode.

Fixes: #836


Some notes on this:

I am not a fan of how I've got the ParseArgs stuff working – specifically, the abort_on_uncaught_exc_ hangs off of the Environment object (which seems correct) but is also stored globally in a static boolean in node.cc. This is mostly out of expedience, since the environment hasn't been created yet, but I want to preserve the initial value. This feels bad, I am open to suggestions on how to make that better.

This does add the overhead of one branch to all MakeCallback calls. I'm not sure if there's a way to get around this, though.

Currently it does not respond to changes from require('v8').setFlagsFromString. I wanted to get a read on the approach before complicating that code.

R=@trevnorris + @bnoordhuis, /cc @geek

If run with --abort-on-uncaught-exception, V8 will abort the process
whenever it does not see a JS-installed CatchClause in the stack. C++
TryCatch clauses are ignored. Domains work by setting a FatalException
handler which is ignored when running in abort mode.

This patch modifies MakeCallback to call its target function through a
JS function that installs a CatchClause and manually calls _fatalException
on error, if the process is both using domains and is in abort mode.

Fixes: #836
@chrisdickinson
Copy link
Contributor Author

Closing this for a second while I work out some bugs.

@chrisdickinson
Copy link
Contributor Author

Okay, I think this is in a better state now.

@geek
Copy link
Member

geek commented Feb 23, 2015

Looks great, no floating patch in v8 land and the code is straightforward.

if (has_abort_on_uncaught_and_domains) {
Local<Value> fn = process->Get(env()->domain_abort_uncaught_exc_string());
if (fn->IsFunction()) {
Local<Array> specialContext = Array::New(env()->isolate(), 2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor style nit: snake_case, not camelCase.

@bnoordhuis
Copy link
Member

LGTM with comments. V8 accepts mixed dashes and underscores in command line arguments while your patch accepts only one or the other but I don't think it matters much in practice.

chrisdickinson added a commit that referenced this pull request Feb 25, 2015
If run with --abort-on-uncaught-exception, V8 will abort the process
whenever it does not see a JS-installed CatchClause in the stack. C++
TryCatch clauses are ignored. Domains work by setting a FatalException
handler which is ignored when running in abort mode.

This patch modifies MakeCallback to call its target function through a
JS function that installs a CatchClause and manually calls _fatalException
on error, if the process is both using domains and is in abort mode.

Semver: patch
PR-URL: #922
Fixes: #836
Reviewed-By: Ben Noordhuis <[email protected]>
@chrisdickinson
Copy link
Contributor Author

Merged in 0af4c9e.

@rvagg
Copy link
Member

rvagg commented Feb 26, 2015

@chrisdickinson could this be considered semver-minor?

@chrisdickinson
Copy link
Contributor Author

Semver-patch.

@trevnorris
Copy link
Contributor

@chrisdickinson You forgot to implement the same for node::MakeCallback().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants