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: make cross-context MakeCallback() calls work #9221

Merged
merged 1 commit into from Oct 25, 2016

Conversation

@bnoordhuis
Copy link
Member

commented Oct 21, 2016

return handle_scope.Escape(Local<Value>::New(
isolate,
MakeCallback(env, recv.As<Value>(), callback, argc, argv)));
Environment* env = Environment::GetCurrent(callback->CreationContext());

This comment has been minimized.

Copy link
@bnoordhuis

bnoordhuis Oct 21, 2016

Author Member

callback->CreationContext() seems a little more correct than recv->CreationContext() because the former is the context the actual callback takes place in but it's admittedly a mostly academic difference.

@mscdex mscdex added the C++ label Oct 21, 2016

@mscdex mscdex referenced this pull request Oct 21, 2016
@bnoordhuis

This comment has been minimized.

Copy link
Member Author

commented Oct 24, 2016

@addaleax Your thoughts, please?

@addaleax
Copy link
Member

left a comment

LGTM

(sorry for not reviewing sooner, as mentioned I’ll be somewhat more busy now that classes have started again)

@addaleax addaleax added the lib / src label Oct 24, 2016

src: make cross-context MakeCallback() calls work
Check that invoking a callback on a receiver from a different context
works.

It ran afoul of an `env->context() == isolate->GetCurrentContext()`
assertion so retrieve the environment from the callback context and
the context to enter from the environment's context() method.

We could also have retrieved the environment from the receiver's context
and that would have made little practical difference.  It just seemed
more correct to get it from the callback context because that is the
actual execution context.

PR-URL: #9221
Reviewed-By: Anna Henningsen <anna@addaleax.net>

@bnoordhuis bnoordhuis force-pushed the bnoordhuis:fix-foreign-context-callback branch to 921d2b0 Oct 25, 2016

@bnoordhuis bnoordhuis closed this Oct 25, 2016

@bnoordhuis bnoordhuis deleted the bnoordhuis:fix-foreign-context-callback branch Oct 25, 2016

@bnoordhuis

This comment has been minimized.

Copy link
Member Author

commented Oct 25, 2016

No problem, thanks for reviewing.

@bnoordhuis bnoordhuis merged commit 921d2b0 into nodejs:master Oct 25, 2016

evanlucas added a commit that referenced this pull request Nov 3, 2016
src: make cross-context MakeCallback() calls work
Check that invoking a callback on a receiver from a different context
works.

It ran afoul of an `env->context() == isolate->GetCurrentContext()`
assertion so retrieve the environment from the callback context and
the context to enter from the environment's context() method.

We could also have retrieved the environment from the receiver's context
and that would have made little practical difference.  It just seemed
more correct to get it from the callback context because that is the
actual execution context.

PR-URL: #9221
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@MylesBorins

This comment has been minimized.

Copy link
Member

commented Nov 18, 2016

@bnoordhuis should this be backported?

@gibfahn gibfahn referenced this pull request Jun 15, 2017
2 of 3 tasks complete
@gibfahn

This comment has been minimized.

Copy link
Member

commented Jun 17, 2017

@bnoordhuis should this be backported?

ping @bnoordhuis

@addaleax

This comment has been minimized.

Copy link
Member

commented Jun 18, 2017

@gibfahn I think this is good to be backported too.

gibfahn added a commit that referenced this pull request Jun 18, 2017
src: make cross-context MakeCallback() calls work
Check that invoking a callback on a receiver from a different context
works.

It ran afoul of an `env->context() == isolate->GetCurrentContext()`
assertion so retrieve the environment from the callback context and
the context to enter from the environment's context() method.

We could also have retrieved the environment from the receiver's context
and that would have made little practical difference.  It just seemed
more correct to get it from the callback context because that is the
actual execution context.

PR-URL: #9221
Reviewed-By: Anna Henningsen <anna@addaleax.net>

@gibfahn gibfahn added land-on-v6.x and removed lts-watch-v6.x labels Jun 18, 2017

gibfahn added a commit that referenced this pull request Jun 20, 2017
src: make cross-context MakeCallback() calls work
Check that invoking a callback on a receiver from a different context
works.

It ran afoul of an `env->context() == isolate->GetCurrentContext()`
assertion so retrieve the environment from the callback context and
the context to enter from the environment's context() method.

We could also have retrieved the environment from the receiver's context
and that would have made little practical difference.  It just seemed
more correct to get it from the callback context because that is the
actual execution context.

PR-URL: #9221
Reviewed-By: Anna Henningsen <anna@addaleax.net>
MylesBorins added a commit that referenced this pull request Jul 11, 2017
src: make cross-context MakeCallback() calls work
Check that invoking a callback on a receiver from a different context
works.

It ran afoul of an `env->context() == isolate->GetCurrentContext()`
assertion so retrieve the environment from the callback context and
the context to enter from the environment's context() method.

We could also have retrieved the environment from the receiver's context
and that would have made little practical difference.  It just seemed
more correct to get it from the callback context because that is the
actual execution context.

PR-URL: #9221
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@MylesBorins MylesBorins referenced this pull request Jul 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.