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 delete operator on vm context #11266

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
6 participants
@fhinkel
Member

fhinkel commented Feb 9, 2017

In the implementation of the vm module, if a property is successfully deleted
on the sandbox, we also need to delete it on the global_proxy object. Therefore, we
must not call args.GetReturnValue().Set().

We only intercept, i.e., call args.GetReturnValue().Set(), in the
DeleterCallback, if Delete() failed, e.g. because
the property was read only.

This is a breaking change, it fixes one of our known issues. But it does not break any
tests in Jest.

Fixes #6287

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

src

If anybody has a better way to word the commit message, I'll happily take it!

@addaleax

LGTM

The commit message seems okay … maybe “delete on vm context”? I think it’s clear what it refers to anyway.

Show outdated Hide outdated src/node_contextify.cc
@@ -456,7 +456,7 @@ class ContextifyContext {
Maybe<bool> success = ctx->sandbox()->Delete(ctx->context(), property);
if (success.IsJust())
if (!success.IsJust() || !success.FromJust())

This comment has been minimized.

@addaleax

addaleax Feb 9, 2017

Member

Maybe if (success.FromMaybe(false)) is a bit more readable?

@addaleax

addaleax Feb 9, 2017

Member

Maybe if (success.FromMaybe(false)) is a bit more readable?

This comment has been minimized.

@fhinkel

fhinkel Feb 10, 2017

Member

Thanks. Done.

@fhinkel

fhinkel Feb 10, 2017

Member

Thanks. Done.

@jasnell

jasnell approved these changes Feb 9, 2017

@bnoordhuis

LGTM. A propos the commit log, my first thought was that it was fixing a bad delete C++ statement. Maybe you can reword it a little, perhaps s/delete/delete operator/?

@fhinkel fhinkel changed the title from src: fix delete in vm module to src: fix delete operator in vm module Feb 10, 2017

@fhinkel fhinkel changed the title from src: fix delete operator in vm module to src: fix delete operator on vm context Feb 10, 2017

src: fix delete operator on vm context
In the implementation of the vm module,
if a property is successfully deleted
on the sandbox, we also need to delete it
on the global_proxy object. Therefore, we
must not call args.GetReturnValue().Set().

We only intercept, i.e., call
args.GetReturnValue().Set(), in the
DeleterCallback, if Delete() failed, e.g. because
the property was read only.

Fixes #6287

jasnell added a commit that referenced this pull request Feb 11, 2017

src: fix delete operator on vm context
In the implementation of the vm module,
if a property is successfully deleted
on the sandbox, we also need to delete it
on the global_proxy object. Therefore, we
must not call args.GetReturnValue().Set().

We only intercept, i.e., call
args.GetReturnValue().Set(), in the
DeleterCallback, if Delete() failed, e.g. because
the property was read only.

PR-URL: #11266
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@jasnell

This comment has been minimized.

Show comment
Hide comment
@jasnell

jasnell Feb 11, 2017

Member

Landed in 0237198

Member

jasnell commented Feb 11, 2017

Landed in 0237198

@jasnell jasnell closed this Feb 11, 2017

italoacasas added a commit that referenced this pull request Feb 13, 2017

src: fix delete operator on vm context
In the implementation of the vm module,
if a property is successfully deleted
on the sandbox, we also need to delete it
on the global_proxy object. Therefore, we
must not call args.GetReturnValue().Set().

We only intercept, i.e., call
args.GetReturnValue().Set(), in the
DeleterCallback, if Delete() failed, e.g. because
the property was read only.

PR-URL: #11266
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>

italoacasas added a commit to italoacasas/node that referenced this pull request Feb 14, 2017

src: fix delete operator on vm context
In the implementation of the vm module,
if a property is successfully deleted
on the sandbox, we also need to delete it
on the global_proxy object. Therefore, we
must not call args.GetReturnValue().Set().

We only intercept, i.e., call
args.GetReturnValue().Set(), in the
DeleterCallback, if Delete() failed, e.g. because
the property was read only.

PR-URL: nodejs#11266
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>

KryDos added a commit to KryDos/node that referenced this pull request Feb 25, 2017

src: fix delete operator on vm context
In the implementation of the vm module,
if a property is successfully deleted
on the sandbox, we also need to delete it
on the global_proxy object. Therefore, we
must not call args.GetReturnValue().Set().

We only intercept, i.e., call
args.GetReturnValue().Set(), in the
DeleterCallback, if Delete() failed, e.g. because
the property was read only.

PR-URL: nodejs#11266
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@jasnell

This comment has been minimized.

Show comment
Hide comment
@jasnell

jasnell Mar 7, 2017

Member

A backport PR is required for this to land in v4

Member

jasnell commented Mar 7, 2017

A backport PR is required for this to land in v4

jasnell added a commit that referenced this pull request Mar 7, 2017

src: fix delete operator on vm context
In the implementation of the vm module,
if a property is successfully deleted
on the sandbox, we also need to delete it
on the global_proxy object. Therefore, we
must not call args.GetReturnValue().Set().

We only intercept, i.e., call
args.GetReturnValue().Set(), in the
DeleterCallback, if Delete() failed, e.g. because
the property was read only.

PR-URL: #11266
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>

MylesBorins added a commit that referenced this pull request Mar 9, 2017

src: fix delete operator on vm context
In the implementation of the vm module,
if a property is successfully deleted
on the sandbox, we also need to delete it
on the global_proxy object. Therefore, we
must not call args.GetReturnValue().Set().

We only intercept, i.e., call
args.GetReturnValue().Set(), in the
DeleterCallback, if Delete() failed, e.g. because
the property was read only.

PR-URL: #11266
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>

@MylesBorins MylesBorins referenced this pull request Mar 9, 2017

Merged

v6.10.1 proposal #11759

gdborton added a commit to gdborton/enzyme that referenced this pull request Mar 23, 2017

Fix an issue w/ cleaning up global.document.
Except in the most recent versions of node, developers are unable to delete
things from global when running code in a node vm.  This means that enzyme is
failing to clean up after itself when temporarily defining global.document for
setState calls.

This papers over the issue by explicitly setting global.document to undefined
if it failed to be deleted.

Relevant jest issue - facebook/jest#3152

Relevant node pr - nodejs/node#11266

gdborton added a commit to gdborton/enzyme that referenced this pull request Mar 24, 2017

Fix an issue w/ cleaning up global.document.
Except in the most recent versions of node, developers are unable to delete
things from global when running code in a node vm.  This means that enzyme is
failing to clean up after itself when temporarily defining global.document for
setState calls.

This papers over the issue by explicitly setting global.document to undefined
before attempting to delete. If the delete succeeds, the undefined value will
be removed.

Relevant jest issue - facebook/jest#3152

Relevant node pr - nodejs/node#11266
@MylesBorins

This comment has been minimized.

Show comment
Hide comment
@MylesBorins

MylesBorins Apr 25, 2017

Member

So it seems that this is causing a failure over at devtools-html/debugger.html#2728

I'm not sure if this is a behavior change on our side, or if the repo in question was relying on the broken behavior

/cc @fhinkel

Member

MylesBorins commented Apr 25, 2017

So it seems that this is causing a failure over at devtools-html/debugger.html#2728

I'm not sure if this is a behavior change on our side, or if the repo in question was relying on the broken behavior

/cc @fhinkel

@MylesBorins

This comment has been minimized.

Show comment
Hide comment
@MylesBorins

MylesBorins Apr 25, 2017

Member

Also worth mentioning... this changed behavior, should we back this out of v6 LTS?

Member

MylesBorins commented Apr 25, 2017

Also worth mentioning... this changed behavior, should we back this out of v6 LTS?

@fhinkel

This comment has been minimized.

Show comment
Hide comment
@fhinkel

fhinkel Apr 26, 2017

Member

Let's leave it out of v6 because it's a breaking change.

Member

fhinkel commented Apr 26, 2017

Let's leave it out of v6 because it's a breaking change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment