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: distinguish env stopping flags #45907

Merged
merged 1 commit into from
Jan 14, 2023

Conversation

legendecas
Copy link
Member

@legendecas legendecas commented Dec 19, 2022

Currently, !env->can_call_into_js() and env->is_stopping() have different semantics by their names. The is_stopping() flag implies !env->can_call_into_js().

However, this implication is not enforced in Environment::FreeEnvironment. Environment::FreeEnvironment creates a DisallowJavascriptExecutionScope, the flag Environment::can_call_into_js() needs to be set as false.

As Environment::can_call_into_js_ is a simple boolean flag, it should not be accessed off-thread. This also fixes an issue that the flag Environment::can_call_into_js_ is been modified in Environment::ExitEnv, which may be called from other threads.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/http2
  • @nodejs/modules
  • @nodejs/net
  • @nodejs/vm

@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. labels Dec 19, 2022
src/api/environment.cc Outdated Show resolved Hide resolved
src/env.h Outdated Show resolved Hide resolved
src/module_wrap.cc Outdated Show resolved Hide resolved
src/node_contextify.cc Outdated Show resolved Hide resolved
src/env-inl.h Outdated Show resolved Hide resolved
@legendecas legendecas added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 5, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 5, 2023
@nodejs-github-bot
Copy link
Collaborator

`Environment::FreeEnvironment` creates a
`DisallowJavascriptExecutionScope`, so the flag
`Environment::can_call_into_js()` should also be set as `false`. As
`Environment::can_call_into_js_` is a simple boolean flag, it should not
be accessed off-threads.
@legendecas legendecas added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 8, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 8, 2023
@nodejs-github-bot
Copy link
Collaborator

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.

I've spent a bit of time trying to figure out those lines of code.

I'd be more comfortable with an added test for this change, but I agree it might be very hard to check.

@nodejs-github-bot
Copy link
Collaborator

@mcollina mcollina added commit-queue Add this label to land a pull request using GitHub Actions. and removed needs-ci PRs that need a full CI run. labels Jan 14, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jan 14, 2023
@nodejs-github-bot nodejs-github-bot merged commit bb40507 into nodejs:main Jan 14, 2023
@nodejs-github-bot
Copy link
Collaborator

Landed in bb40507

RafaelGSS pushed a commit to RafaelGSS/node that referenced this pull request Jan 17, 2023
`Environment::FreeEnvironment` creates a
`DisallowJavascriptExecutionScope`, so the flag
`Environment::can_call_into_js()` should also be set as `false`. As
`Environment::can_call_into_js_` is a simple boolean flag, it should not
be accessed off-threads.

PR-URL: nodejs#45907
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
RafaelGSS pushed a commit that referenced this pull request Jan 20, 2023
`Environment::FreeEnvironment` creates a
`DisallowJavascriptExecutionScope`, so the flag
`Environment::can_call_into_js()` should also be set as `false`. As
`Environment::can_call_into_js_` is a simple boolean flag, it should not
be accessed off-threads.

PR-URL: #45907
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@RafaelGSS RafaelGSS mentioned this pull request Jan 20, 2023
juanarbol pushed a commit that referenced this pull request Jan 26, 2023
`Environment::FreeEnvironment` creates a
`DisallowJavascriptExecutionScope`, so the flag
`Environment::can_call_into_js()` should also be set as `false`. As
`Environment::can_call_into_js_` is a simple boolean flag, it should not
be accessed off-threads.

PR-URL: #45907
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@juanarbol juanarbol mentioned this pull request Jan 28, 2023
juanarbol pushed a commit that referenced this pull request Jan 31, 2023
`Environment::FreeEnvironment` creates a
`DisallowJavascriptExecutionScope`, so the flag
`Environment::can_call_into_js()` should also be set as `false`. As
`Environment::can_call_into_js_` is a simple boolean flag, it should not
be accessed off-threads.

PR-URL: #45907
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@bcoe bcoe mentioned this pull request Dec 18, 2023
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants