Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Port #8666 from v0.10 to v0.12 #8877

Closed
misterdjules opened this issue Dec 16, 2014 · 5 comments
Closed

Port #8666 from v0.10 to v0.12 #8877

misterdjules opened this issue Dec 16, 2014 · 5 comments

Comments

@misterdjules
Copy link

Recently, when merging v0.10 into v0.12, the commits from #8666 could not be merged because v0.10 and v0.12 diverged a lot in the areas that this PR touches.

Thus, we should manually forward port #8666 from v0.10 to v0.12 as soon as possible.

@misterdjules misterdjules self-assigned this Dec 16, 2014
@misterdjules misterdjules added this to the 0.12.1 milestone Dec 16, 2014
@misterdjules misterdjules modified the milestones: 0.12.3, 0.12.2 Apr 1, 2015
@misterdjules misterdjules modified the milestones: 0.12.3, 0.12.4 May 14, 2015
@misterdjules misterdjules modified the milestones: 0.12.4, 0.12.5 May 25, 2015
@misterdjules misterdjules modified the milestones: 0.12.5, 0.12.6 Jun 22, 2015
@misterdjules
Copy link
Author

I'm available to guide anyone willing to pick this issue up and submit a PR that fixes it. Ping me on GitHub by mentioning @misterdjules or find me on IRC (jgi in #libuv on Freenode).

EDIT: I'm also available by email at jgilli at fastmail dot fm.

@misterdjules misterdjules modified the milestones: 0.12.6, 0.12.7, 0.12.8 Jul 6, 2015
@whitlockjc
Copy link

If no one else has jumped on this, I'd love to do this.

@misterdjules
Copy link
Author

@whitlockjc That's awesome, thank you! 👍

Just a few recommendations before you tackle this one:

  1. I would start by getting test/simple/test-domain-top-level-error-handler-throw.js to work in v0.12. Just git checkout upstream/v0.10 test/simple/test-domain-top-level-error-handler-throw.js from a local checkout of v0.12, build node and run ./node test/simple/test-domain-top-level-error-handler-throw.js to reproduce the problem.

    Make sure you understand the goal of this test as described in the inline comments. The changes that fix this test in the original PR (domains: fix issues with abort on uncaught #8666) are only the changes made to process._fatalException in src/node.js. The implementation of domains and the way exceptions are handled by node is a bit different in v0.12 compared to v0.10, so even though the changes you'll need to make will be similar, they will probably need to be adapted/moved to the proper place.

  2. Once 1) is done, I would try to get test/simple/test-domain-with-abort-on-uncaught-exception.js to pass too in the same manner. In the original PR (domains: fix issues with abort on uncaught #8666), the changes that fix this problem are all the changes but the ones in src/node.js. Basically, in v0.10 it meant adding a SetAbortOnUncaughtException function to V8's APIs, which sets a callback that is called when a JavaScript exception is thrown. That callback determines if either there's no domain active currently, or if the active domain is at the top of the domains stack. If so it aborts, if not it doesn't. I believe we can probably adapt this almost as is for V8 and node in v0.12.

    Once that test pass, you'll want to make sure that when the process aborts, it aborts at the right time. One way to do this is to run a node program similar to the following:

    var domain = require('domain');
    var d = domain.create();
    var fs = require('fs');
    d.on('error', function() {
    throw new Error('from domain error handler');
    });
    
    d.run(function doStuff() {
    process.nextTick(function() {
        throw new Error('from nextTick callback');
    });
    });
    

    and make it generate a core dump. Then load that core dump with mdb_v8 on SmartOS and run ::jsstack and make sure the callstack makes sense (that is the last JavaScript frame is the domain error handler, etc.).

    But we can go through that latest part once the rest is done.

Please let us know if you need anything else!

whitlockjc added a commit to whitlockjc/node-v0.x-archive that referenced this issue Aug 10, 2015
Port fbff705 and caeb677 from v0.10 to v0.12, original commit messages:

  fbff705
  Add v8::Isolate::SetAbortOnUncaughtException() so the user can be
  notified when an uncaught exception has bubbled.

  caeb677
  Do not abort the process if an error is thrown from within a domain,
  an error handler is setup for the domain and
  --abort-on-uncaught-exception was passed on the command line.

  However, if an error is thrown from within the top-level domain's
  error handler and --abort-on-uncaught-exception was passed on the
  command line, make the process abort.

Fixes: nodejs#8877
whitlockjc added a commit to whitlockjc/node-v0.x-archive that referenced this issue Aug 11, 2015
Port fbff705 and caeb677 from v0.10 to v0.12, original commit messages:

  fbff705
  Add v8::Isolate::SetAbortOnUncaughtException() so the user can be
  notified when an uncaught exception has bubbled.

  caeb677
  Do not abort the process if an error is thrown from within a domain,
  an error handler is setup for the domain and
  --abort-on-uncaught-exception was passed on the command line.

  However, if an error is thrown from within the top-level domain's
  error handler and --abort-on-uncaught-exception was passed on the
  command line, make the process abort.

Fixes: nodejs#8877
whitlockjc added a commit to whitlockjc/node-v0.x-archive that referenced this issue Aug 12, 2015
Port fbff705 and caeb677 from v0.10 to v0.12, original commit messages:

  fbff705
  Add v8::Isolate::SetAbortOnUncaughtException() so the user can be
  notified when an uncaught exception has bubbled.

  caeb677
  Do not abort the process if an error is thrown from within a domain,
  an error handler is setup for the domain and
  --abort-on-uncaught-exception was passed on the command line.

  However, if an error is thrown from within the top-level domain's
  error handler and --abort-on-uncaught-exception was passed on the
  command line, make the process abort.

Fixes: nodejs#8877
whitlockjc added a commit to whitlockjc/node-v0.x-archive that referenced this issue Sep 28, 2015
Port fbff705 and caeb677 from v0.10 to v0.12, original commit messages:

  fbff705
  Add v8::Isolate::SetAbortOnUncaughtException() so the user can be
  notified when an uncaught exception has bubbled.

  caeb677
  Do not abort the process if an error is thrown from within a domain,
  an error handler is setup for the domain and
  --abort-on-uncaught-exception was passed on the command line.

  However, if an error is thrown from within the top-level domain's
  error handler and --abort-on-uncaught-exception was passed on the
  command line, make the process abort.

Fixes: nodejs#8877
whitlockjc added a commit to whitlockjc/node-v0.x-archive that referenced this issue Sep 28, 2015
caeb677
Do not abort the process if an error is thrown from within a domain,
an error handler is setup for the domain and
--abort-on-uncaught-exception was passed on the command line.

However, if an error is thrown from within the top-level domain's
error handler and --abort-on-uncaught-exception was passed on the
command line, make the process abort.

Fixes: nodejs#8877
misterdjules pushed a commit to nodejs/node that referenced this issue Oct 1, 2015
fbff705
Add v8::Isolate::SetAbortOnUncaughtException() so the user can be
notified when an uncaught exception has bubbled.

Fixes: nodejs/node-v0.x-archive#8877
PR-URL: nodejs/node-v0.x-archive#25835
Reviewed-By: misterdjules - Julien Gilli <jgilli@nodejs.org>
misterdjules pushed a commit to nodejs/node that referenced this issue Oct 1, 2015
caeb677
Do not abort the process if an error is thrown from within a domain,
an error handler is setup for the domain and
--abort-on-uncaught-exception was passed on the command line.

However, if an error is thrown from within the top-level domain's
error handler and --abort-on-uncaught-exception was passed on the
command line, make the process abort.

Fixes: #8877

Fixes: nodejs/node-v0.x-archive#8877
PR-URL: nodejs/node-v0.x-archive#25835
Reviewed-By: misterdjules - Julien Gilli <jgilli@nodejs.org>
@misterdjules
Copy link
Author

Fixed by 1982ed6 and f0453ca. Thank you @whitlockjc!

@whitlockjc
Copy link

Any time. Thanks for the help.

jBarz pushed a commit to ibmruntimes/node that referenced this issue Nov 4, 2016
fbff705
Add v8::Isolate::SetAbortOnUncaughtException() so the user can be
notified when an uncaught exception has bubbled.

Fixes: nodejs#8877
PR-URL: nodejs#25835
Reviewed-By: misterdjules - Julien Gilli <jgilli@nodejs.org>
jBarz pushed a commit to ibmruntimes/node that referenced this issue Nov 4, 2016
caeb677
Do not abort the process if an error is thrown from within a domain,
an error handler is setup for the domain and
--abort-on-uncaught-exception was passed on the command line.

However, if an error is thrown from within the top-level domain's
error handler and --abort-on-uncaught-exception was passed on the
command line, make the process abort.

Fixes: nodejs#8877

Fixes: nodejs#8877
PR-URL: nodejs#25835
Reviewed-By: misterdjules - Julien Gilli <jgilli@nodejs.org>
jBarz added a commit to ibmruntimes/v8z that referenced this issue Feb 1, 2017
this was cherry-picked manually

    fbff705
    Add v8::Isolate::SetAbortOnUncaughtException() so the user can be
    notified when an uncaught exception has bubbled.

    Fixes: nodejs/node-v0.x-archive#8877
    PR-URL: nodejs/node-v0.x-archive#25835
    Reviewed-By: misterdjules - Julien Gilli <jgilli@nodejs.org>
jBarz pushed a commit to ibmruntimes/node that referenced this issue Feb 1, 2017
caeb677
Do not abort the process if an error is thrown from within a domain,
an error handler is setup for the domain and
--abort-on-uncaught-exception was passed on the command line.

However, if an error is thrown from within the top-level domain's
error handler and --abort-on-uncaught-exception was passed on the
command line, make the process abort.

Fixes: nodejs#8877

Fixes: nodejs#8877
PR-URL: nodejs#25835
Reviewed-By: misterdjules - Julien Gilli <jgilli@nodejs.org>

Conflicts:
	lib/domain.js
	src/env.h
	test/simple/test-domain-with-abort-on-uncaught-exception.js
mcornac pushed a commit to ibmruntimes/v8z that referenced this issue Feb 2, 2017
this was cherry-picked manually

    fbff705
    Add v8::Isolate::SetAbortOnUncaughtException() so the user can be
    notified when an uncaught exception has bubbled.

    Fixes: nodejs/node-v0.x-archive#8877
    PR-URL: nodejs/node-v0.x-archive#25835
    Reviewed-By: misterdjules - Julien Gilli <jgilli@nodejs.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants