Uh oh!
There was an error while loading. Please reload this page.
src: handle thrown errors in CopyProperties() - #8649
Conversation
imyller
commented
Sep 18, 2016
There was a problem hiding this comment.
You don't need a TryCatch because...
There was a problem hiding this comment.
...the proper way is to check:
auto maybe_has = sandbox_obj->HasOwnProperty(context, key);
if (!maybe_has.IsJust()) break; // Exception pending.auto has = maybe_has.FromJust();
// ...There was a problem hiding this comment.
You don't need to ReThrow() if you drop the TryCatch, the exception will simply bubble up.
(I believe the caller of CopyProperties() is doing that wrong, too.)
cjihrig
commented
Sep 19, 2016
Thanks @bnoordhuis. Updated with your suggestions. |
There was a problem hiding this comment.
tiny nit: I would be okay with just keeping the bool type explicit, using auto here doesn’t save any space and erases information that a reader of the code may find helpful.
cjihrig
commented
Sep 19, 2016
@addaleax done. |
bnoordhuis
commented
Sep 20, 2016
Tangential: CopyProperties() doesn't look very rigorous to me. GetOwnPropertyNames() returns only enumerable string properties; no symbols, no non-enumerable properties. Perhaps only enumerable makes some sense because you don't want to copy over globals like Array and Date. |
fhinkel
commented
Sep 20, 2016
FYI: We made API changes upstream in V8, so CopyProperties() will go away soon. |
fhinkel
commented
Sep 20, 2016
Can you add a regression test? |
cjihrig
commented
Sep 20, 2016
@fhinkel what do you mean? I thought I did (see the other changed file) :-) |
fhinkel
commented
Sep 20, 2016
So sorry, I must have completely missed that! LGTM. |
jasnell
commented
Sep 20, 2016
This commit prevents thrown JavaScript exceptions from crashing the process in node_contextify's CopyProperties() function. Fixes: nodejs#8537 PR-URL: nodejs#8649 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
MylesBorins
commented
Oct 6, 2016
@cjihrig I've set this as do not land as proxies are not on v4.x Let me know if I'm mistaken here |
bnoordhuis
commented
Oct 7, 2016
I think it would be good to back-port, it's not just proxies that can cause exceptions. |
This commit prevents thrown JavaScript exceptions from crashing the process in node_contextify's CopyProperties() function. Fixes: #8537 PR-URL: #8649 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Checklist
make -j4 test(UNIX), orvcbuild test nosign(Windows) passesAffected core subsystem(s)
src
Description of change
This commit prevents thrown JavaScript exceptions from crashing the process in
node_contextify'sCopyProperties()function.Closes#8537