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

Revert "n-api: detect deadlocks in thread-safe function" #33453

Closed
wants to merge 4 commits into from

Conversation

addaleax
Copy link
Member

This reverts commit d26ca06 because
it breaks running the tests in debug mode, as
v8::Isolate::GetCurrent() is not allowed if no Isolate is active
on the current thread.

Refs: #33276
Refs: #32860

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • documentation is changed or added
  • commit message follows commit guidelines

This reverts commit d26ca06 because
it breaks running the tests in debug mode, as
`v8::Isolate::GetCurrent()` is not allowed if no `Isolate` is active
on the current thread.

Refs: nodejs#33276
Refs: nodejs#32860
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. node-api Issues and PRs related to the Node-API. labels May 18, 2020
Copy link
Contributor

@gabrielschulhof gabrielschulhof left a comment

Choose a reason for hiding this comment

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

napi_would_deadlock is part of at least 14.1.0, so IINM removing it would be semver-major. Shouldn't we instead think of a better way of detecting whether we are on a JS thread?

@gabrielschulhof
Copy link
Contributor

How can you detect whether you are on a JS thread or not without knowing a priori that you are on a JS thread? Is there a way of finding out whether an isolate is active on the current thread without calling v8::Isolate::GetCurrent()?

@addaleax
Copy link
Member Author

napi_would_deadlock is part of at least 14.1.0, so IINM removing it would be semver-major.

@gabrielschulhof Hm right, we should probably leave the enum value in place. I’ll update the PR.

Shouldn't we instead think of a better way of detecting whether we are on a JS thread?

Yes. That hasn’t happened for 11 days since #33276 was opened, hence the revert PR now.

How can you detect whether you are on a JS thread or not without knowing a priori that you are on a JS thread? Is there a way of finding out whether an isolate is active on the current thread without calling v8::Isolate::GetCurrent()?

I wasn’t aware that Isolate::GetCurrent() is invalid, which is why I suggested it, but I don’t really know of any alternatives.

@addaleax
Copy link
Member Author

@gabrielschulhof I’ve added the definition back to the header/the doc, PTAL

(I’m assuming that your objection was about API/ABI compatibility and not the revert of the feature itself?)

@gabrielschulhof gabrielschulhof dismissed their stale review May 18, 2020 15:43

@addaleax I'm not too fond of the revert either, because I'm frustrated by the fact that we have no way of detecting that we are on a JS thread, but I understand the reason for it. I guess, with the enum value in place we have secured the option of eventually actually, possibly returning that value, once we've figured out how to properly detect that we are on a JS thread.

Copy link
Contributor

@gabrielschulhof gabrielschulhof left a comment

Choose a reason for hiding this comment

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

If we replace the comments in the documentation instead of removing the entirely, we'll at least have some sort of fix for the original issue.

@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 18, 2020
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

Copy link
Contributor

@gabrielschulhof gabrielschulhof left a comment

Choose a reason for hiding this comment

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

@addaleax question before this lands: Can we use node::Environment::GetThreadLocalEnv() to determine whether we are on a JS thread?

@gabrielschulhof
Copy link
Contributor

I mean, instead of v8::Isolate::GetCurrent()?

@gabrielschulhof
Copy link
Contributor

@addaleax like so (still running the tests locally, so no PR yet).

@addaleax addaleax removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 19, 2020
@addaleax
Copy link
Member Author

@gabrielschulhof Currently yes, but we should get rid of that API, and it won’t work when an Environment/Isolate is moved between threads. I don’t think that would be a good idea.

Ultimately, this is a programmer error and there are tools that help diagnose this kind of situation. If we can’t come up with a good solution that doesn’t yield false positives, we should let this be.

@gabrielschulhof gabrielschulhof dismissed their stale review May 19, 2020 21:00

@addaleax gotcha! Thanks for clarifying!

BridgeAR pushed a commit to BridgeAR/node that referenced this pull request May 23, 2020
This reverts commit d26ca06 because
it breaks running the tests in debug mode, as
`v8::Isolate::GetCurrent()` is not allowed if no `Isolate` is active
on the current thread.

Refs: nodejs#33276
Refs: nodejs#32860

PR-URL: nodejs#33453
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Gabriel Schulhof <[email protected]>
@BridgeAR
Copy link
Member

Landed in b18d8dd

@BridgeAR BridgeAR closed this May 23, 2020
codebytere pushed a commit that referenced this pull request Jun 18, 2020
This reverts commit d26ca06 because
it breaks running the tests in debug mode, as
`v8::Isolate::GetCurrent()` is not allowed if no `Isolate` is active
on the current thread.

Refs: #33276
Refs: #32860

PR-URL: #33453
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Gabriel Schulhof <[email protected]>
codebytere pushed a commit that referenced this pull request Jun 18, 2020
This reverts commit d26ca06 because
it breaks running the tests in debug mode, as
`v8::Isolate::GetCurrent()` is not allowed if no `Isolate` is active
on the current thread.

Refs: #33276
Refs: #32860

PR-URL: #33453
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Gabriel Schulhof <[email protected]>
@codebytere codebytere mentioned this pull request Jun 28, 2020
codebytere pushed a commit that referenced this pull request Jun 30, 2020
This reverts commit d26ca06 because
it breaks running the tests in debug mode, as
`v8::Isolate::GetCurrent()` is not allowed if no `Isolate` is active
on the current thread.

Refs: #33276
Refs: #32860

PR-URL: #33453
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Gabriel Schulhof <[email protected]>
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++. node-api Issues and PRs related to the Node-API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants