diff options
author | Anna Henningsen <anna@addaleax.net> | 2017-11-29 20:55:43 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2017-12-05 23:49:36 +0100 |
commit | b73e66e94918aa89643b982cd3164100d02ec997 (patch) | |
tree | e23a4188d6330d7ea7bd34e9c04689c6f032cc5c /lib/vm.js | |
parent | aeddc3676bc9afe940106d34f30523f27b4cb44f (diff) | |
download | android-node-v8-b73e66e94918aa89643b982cd3164100d02ec997.tar.gz android-node-v8-b73e66e94918aa89643b982cd3164100d02ec997.tar.bz2 android-node-v8-b73e66e94918aa89643b982cd3164100d02ec997.zip |
vm: never abort on caught syntax error
Keep track of C++ `TryCatch` state to avoid aborting when
an exception is thrown inside one, and re-throw in JS
to make sure the exception is being picked up a second time by
a second uncaught exception handler, if necessary.
Add a bit of a hack to `AppendExceptionLine` to avoid overriding
the line responsible for re-throwing the exception.
PR-URL: https://github.com/nodejs/node/pull/17394
Fixes: https://github.com/nodejs/node/issues/13258
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/vm.js')
-rw-r--r-- | lib/vm.js | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -22,7 +22,7 @@ 'use strict'; const { - ContextifyScript: Script, + ContextifyScript, kParsingContext, makeContext, @@ -39,6 +39,19 @@ const { // - isContext(sandbox) // From this we build the entire documented API. +class Script extends ContextifyScript { + constructor(code, options) { + // Calling `ReThrow()` on a native TryCatch does not generate a new + // abort-on-uncaught-exception check. A dummy try/catch in JS land + // protects against that. + try { + super(code, options); + } catch (e) { + throw e; /* node-do-not-add-exception-line */ + } + } +} + const realRunInThisContext = Script.prototype.runInThisContext; const realRunInContext = Script.prototype.runInContext; |