FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

src: fix crash on FSReqPromise destructor by santigimeno · Pull Request #43533 · nodejs/node · GitHub

/ node Public

src: fix crash on FSReqPromise destructor - #43533

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
santigimeno:santi/fix_43499
Jul 9, 2022
Merged

src: fix crash on FSReqPromise destructor#43533
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
santigimeno:santi/fix_43499

Conversation

Copy link
Copy Markdown
Member

We are deciding whether to end fs promises by checking
can_call_into_js() whereas in the FSReqPromise destructor we're
using the is_stopping() check. Though this may look as semantically
correct it has issues because though both values are modified before
termination on Environment::ExitEnv() and both are atomic they are not
synchronized together so it may happen that when reaching the destructor
call_into_js may be set to false whereas is_stopping remains
false causing the crash. Fix this by using the same checks everywhere.

Fixes: #43499

nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Jun 22, 2022

santigimeno commented Jun 22, 2022
edited
Loading

Copy link
Copy Markdown
Member Author

/cc @addaleax as you already commented in the original PR. Do you think this is the correct approach or just use the can_call_into_js() everywhere? Thanks

Copy link
Copy Markdown
Member

Do you think this is the correct approach or just use the can_call_into_js() everywhere?

I’d turn the line in the destructor into CHECK_IMPLIES(!finished_, !env()->can_call_into_js());, yeah. During the original review I missed that this is about checking that the precondition for not finishing (which should be !env->can_call_into_js()) was fulfilled if the promise wasn’t finished, rather than being a standalone check that was unrelated to the other conditionals introduced in the original PR.

We are deciding whether to end `fs` promises by checking
`can_call_into_js()` whereas in the `FSReqPromise` destructor we're
using the `is_stopping()` check. Though this may look as semantically
correct it has issues because though both values are modified before
termination on `Environment::ExitEnv()` and both are atomic they are not
syncronized together so it may happen that when reaching the destructor
`call_into_js` may be set to `false` whereas `is_stopping` remains
`false` causing the crash. Fix this by checking with
`can_call_into_js()` also in the destructor.

Fixes: nodejs#43499

Copy link
Copy Markdown
Member Author

@addaleax I've updated the PR with your suggestion. Thanks!!
While we're here, one question if you don't mind: I understand the difference in semantics between stopping and can_call_into_js but while looking at where and when they're set it's not completely clear to me why they can't be folded into one variable. Could you clarify it? Thanks in advance

santigimeno added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 22, 2022
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 22, 2022

This comment was marked as outdated.

Copy link
Copy Markdown
Member

I understand the difference in semantics between stopping and can_call_into_js but while looking at where and when they're set it's not completely clear to me why they can't be folded into one variable. Could you clarify it? Thanks in advance

I think that is potentially possible for sure, but as you mention, there is a difference in semantics. I could imagine us setting can_call_into_js to false temporarily if we introduce a DisallowJavascriptExecutionScope at some point, for example, but that shouldn’t affect is_stopping.

santigimeno added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 23, 2022
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 23, 2022

This comment was marked as outdated.

F3n67u added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 25, 2022
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 25, 2022

This comment was marked as outdated.

lpinca added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 26, 2022
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 26, 2022

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

Copy link
Copy Markdown
Member

The Jenkins CI attempts to rebase before running the tests, so a manual rebase is not strictly necessary.

F3n67u commented Jun 29, 2022
edited
Loading

Copy link
Copy Markdown
Contributor

The Jenkins CI attempts to rebase before running the tests, so a manual rebase is not strictly necessary.

I dont know that. Thanks for the info. Then let us rerun the ci and see if ci is happy now.

F3n67u added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 29, 2022
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 29, 2022

This comment was marked as outdated.

F3n67u added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 29, 2022
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 29, 2022

This comment was marked as outdated.

F3n67u added flaky-test Issues and PRs related to the tests with unstable failures on the CI. author ready PRs that have at least one approval, no outstanding review comments, and a CI started. labels Jun 30, 2022

F3n67u commented Jul 3, 2022

Copy link
Copy Markdown
Contributor

Hi, collaborators. could you help to trigger another resume ci run?

The last ci failure is mainly caused by flaky test-stream-finished. This test is already fixed by #43641. we could trigger another ci run.

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Collaborator

aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 9, 2022
nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 9, 2022
nodejs-github-bot merged commit 92d26e7 into nodejs:main Jul 9, 2022

Copy link
Copy Markdown
Collaborator

Landed in 92d26e7

targos pushed a commit that referenced this pull request Jul 12, 2022
We are deciding whether to end `fs` promises by checking
`can_call_into_js()` whereas in the `FSReqPromise` destructor we're
using the `is_stopping()` check. Though this may look as semantically
correct it has issues because though both values are modified before
termination on `Environment::ExitEnv()` and both are atomic they are not
syncronized together so it may happen that when reaching the destructor
`call_into_js` may be set to `false` whereas `is_stopping` remains
`false` causing the crash. Fix this by checking with
`can_call_into_js()` also in the destructor.

Fixes: #43499

PR-URL: #43533
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this pull request Jul 20, 2022
We are deciding whether to end `fs` promises by checking
`can_call_into_js()` whereas in the `FSReqPromise` destructor we're
using the `is_stopping()` check. Though this may look as semantically
correct it has issues because though both values are modified before
termination on `Environment::ExitEnv()` and both are atomic they are not
syncronized together so it may happen that when reaching the destructor
`call_into_js` may be set to `false` whereas `is_stopping` remains
`false` causing the crash. Fix this by checking with
`can_call_into_js()` also in the destructor.

Fixes: #43499

PR-URL: #43533
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this pull request Jul 31, 2022
We are deciding whether to end `fs` promises by checking
`can_call_into_js()` whereas in the `FSReqPromise` destructor we're
using the `is_stopping()` check. Though this may look as semantically
correct it has issues because though both values are modified before
termination on `Environment::ExitEnv()` and both are atomic they are not
syncronized together so it may happen that when reaching the destructor
`call_into_js` may be set to `false` whereas `is_stopping` remains
`false` causing the crash. Fix this by checking with
`can_call_into_js()` also in the destructor.

Fixes: #43499

PR-URL: #43533
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
guangwong pushed a commit to noslate-project/node that referenced this pull request Oct 10, 2022
We are deciding whether to end `fs` promises by checking
`can_call_into_js()` whereas in the `FSReqPromise` destructor we're
using the `is_stopping()` check. Though this may look as semantically
correct it has issues because though both values are modified before
termination on `Environment::ExitEnv()` and both are atomic they are not
syncronized together so it may happen that when reaching the destructor
`call_into_js` may be set to `false` whereas `is_stopping` remains
`false` causing the crash. Fix this by checking with
`can_call_into_js()` also in the destructor.

Fixes: nodejs/node#43499

PR-URL: nodejs/node#43533
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no outstanding review comments, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. flaky-test Issues and PRs related to the tests with unstable failures on the CI. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate test-worker-fshandles-open-close-on-termination and test-worker-fshandles-error-on-termination crash

8 participants


Back | FazBrowse Home | New Git URL