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

[v18.x] src: per-realm binding data #47174

Closed

Conversation

legendecas
Copy link
Member

Binding data is inherited from BaseObject and created in a specific realm. They need to be tracked on a per-realm basis so that they can be released properly when a realm is disposed.

PR-URL: #46556
Reviewed-By: Joyee Cheung [email protected]
Reviewed-By: Colin Ihrig [email protected]
Reviewed-By: Matteo Collina [email protected]

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/http2
  • @nodejs/net
  • @nodejs/startup

@legendecas legendecas changed the title src: per-realm binding data [v18.x] src: per-realm binding data Mar 20, 2023
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. v18.x Issues that can be reproduced on v18.x or PRs targeting the v18.x-staging branch. labels Mar 20, 2023
Copy link
Member

@joyeecheung joyeecheung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RSLGTM

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@nodejs-github-bot
Copy link
Collaborator

@danielleadams
Copy link
Contributor

@legendecas are you able to restart the ASan test to confirm it passes before landing in v18? Thanks!

Binding data is inherited from BaseObject and created in a specific
realm. They need to be tracked on a per-realm basis so that they can
be released properly when a realm is disposed.

PR-URL: nodejs#46556
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
# Conflicts:
#	src/dataqueue/queue.cc
@legendecas
Copy link
Member Author

Seems like I can not restart the ASan action either. I've rebased the branch on the tip of v18.x-staging.

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label May 19, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 19, 2023
@nodejs-github-bot
Copy link
Collaborator

@danielleadams
Copy link
Contributor

Landed in 0b92035

danielleadams pushed a commit that referenced this pull request May 29, 2023
Binding data is inherited from BaseObject and created in a specific
realm. They need to be tracked on a per-realm basis so that they can
be released properly when a realm is disposed.

PR-URL: #46556
Backport-PR-URL: #47174
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
# Conflicts:
#	src/dataqueue/queue.cc
@legendecas legendecas deleted the backport-46556-to-18 branch May 29, 2023 02:29
@@ -539,7 +539,8 @@ void Environment::AssignToContext(Local<v8::Context> context,
context->SetAlignedPointerInEmbedderData(ContextEmbedderIndex::kRealm, realm);
// Used to retrieve bindings
context->SetAlignedPointerInEmbedderData(
ContextEmbedderIndex::kBindingListIndex, &(this->bindings_));
ContextEmbedderIndex::kBindingDataStoreIndex,
realm->binding_data_store());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is called from node_contextify.cc like this:

env->AssignToContext(v8_context, nullptr, info);

This appears to get an invalid value in that flow. What's the expected behavior? Should the embedder data be nullptr when realm is nullptr?

Copy link
Contributor

@jkrems jkrems Jul 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't fully looked into how this slot is used but I suspect the fix is:

  // Used to retrieve bindings
  context->SetAlignedPointerInEmbedderData(
      ContextEmbedderIndex::kBindingDataStoreIndex,
      realm != nullptr ? realm->binding_data_store() : nullptr);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sending #48802 in case that is the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. v18.x Issues that can be reproduced on v18.x or PRs targeting the v18.x-staging branch.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants