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: mark ArrayBuffers with free callbacks as untransferable #30475

Closed
wants to merge 2 commits into from

Conversation

addaleax
Copy link
Member

More precisely, make them untransferable if they were created through
our APIs, because those do not follow the improved free callback
mechanism that V8 uses now. All other ArrayBuffers can be transferred
between threads now, the assumption being that they were created in a
clean way that follows the V8 API on this.

This addresses a TODO comment.

Refs: #30339 (comment)

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

More precisely, make them untransferable if they were created through
*our* APIs, because those do not follow the improved free callback
mechanism that V8 uses now. All other ArrayBuffers can be transferred
between threads now, the assumption being that they were created in a
clean way that follows the V8 API on this.

This addresses a TODO comment.

Refs: nodejs#30339 (comment)
@addaleax addaleax added buffer Issues and PRs related to the buffer subsystem. addons Issues and PRs related to native addons. node-api Issues and PRs related to the Node-API. dont-land-on-v10.x labels Nov 13, 2019
@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. labels Nov 13, 2019
@@ -39,6 +39,10 @@ struct napi_env__ {
inline void Unref() { if ( --refs == 0) delete this; }

virtual bool can_call_into_js() const { return true; }
virtual v8::Maybe<bool> mark_arraybuffer_as_untransferable(
v8::Local<v8::ArrayBuffer> ab) const {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: unused ?

Copy link
Member Author

Choose a reason for hiding this comment

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

@devnexen This method is called in js_native_api_v8.cc (right above this file in the github diff)

Copy link
Contributor

@devnexen devnexen Nov 16, 2019

Choose a reason for hiding this comment

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

In fact I mentioned the argument :-) sorry for the confusion.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, the argument is not used here, only in the subclass override

@addaleax addaleax added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. and removed lib / src Issues and PRs related to general changes in the lib or src directory. labels Nov 16, 2019
@nodejs-github-bot
Copy link
Collaborator

@lundibundi
Copy link
Member

Well, we've got an ICE =):
Not sure how to report this considering the amount of code involved.

https://github.com/nodejs/node/commit/44da3b3986f9bb5eb055150456ad99452bd010b5
debian9-docker-armv7

https://ci.nodejs.org/job/node-test-commit-arm/27364/nodes=debian9-docker-armv7/console
https://ci.nodejs.org/job/node-test-commit-arm/nodes=debian9-docker-armv7/27364/timestamps/?time=HH:mm:ss&timeZone=GMT+2&appendLog&locale=en_US


21:56:50 In file included from ../src/env.cc:8:0:
21:56:50 ../src/node_file.h: In member function 'void node::fs::FSReqPromise<AliasedBufferT>::Reject(v8::Local<v8::Value>) [with AliasedBufferT = node::AliasedBufferBase<long long unsigned int, v8::BigUint64Array>]':
21:56:50 ../src/node_file.h:238:69: internal compiler error: Segmentation fault
21:56:50      Local<Promise::Resolver> resolver = value.As<Promise::Resolver>();
21:56:50                                                                      ^
21:56:50 Please submit a full bug report,
21:56:50 with preprocessed source if appropriate.
21:56:50 See <file:///usr/share/doc/gcc-6/README.Bugs> for instructions.

The other error is unused port2 in the test.

@addaleax
Copy link
Member Author

@lundibundi Thanks for pointing that out! I’ve fixed the linting error and will re-start CI.

As for the ICE, I’m not sure if it helps, but I’ll open a PR to do what should have been done anyway, namely move the code of the method that’s causing the crash into the .cc file.

@nodejs-github-bot
Copy link
Collaborator

addaleax added a commit to addaleax/node that referenced this pull request Nov 18, 2019
- Move inline functions into an `-inl.h` file
- Move override function definitions into `.cc` files
- Remove `using` statements from header files
- Make data fields of classes private
- Mark classes at the end of hierarchies as `final`

This is also partially being done in an attempt to avoid
a particular internal compiler error, see
nodejs#30475 (comment)
for details.
@addaleax addaleax mentioned this pull request Nov 18, 2019
2 tasks
@nodejs-github-bot
Copy link
Collaborator

addaleax added a commit that referenced this pull request Nov 19, 2019
More precisely, make them untransferable if they were created through
*our* APIs, because those do not follow the improved free callback
mechanism that V8 uses now. All other ArrayBuffers can be transferred
between threads now, the assumption being that they were created in a
clean way that follows the V8 API on this.

This addresses a TODO comment.

Refs: #30339 (comment)

PR-URL: #30475
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
@addaleax
Copy link
Member Author

Landed in 6cb8e4b

@addaleax addaleax closed this Nov 19, 2019
@addaleax addaleax deleted the buffer-untransferable branch November 19, 2019 13:02
MylesBorins pushed a commit that referenced this pull request Nov 21, 2019
More precisely, make them untransferable if they were created through
*our* APIs, because those do not follow the improved free callback
mechanism that V8 uses now. All other ArrayBuffers can be transferred
between threads now, the assumption being that they were created in a
clean way that follows the V8 API on this.

This addresses a TODO comment.

Refs: #30339 (comment)

PR-URL: #30475
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
@BridgeAR BridgeAR mentioned this pull request Nov 21, 2019
gengjiawen pushed a commit that referenced this pull request Nov 30, 2019
- Move inline functions into an `-inl.h` file
- Move override function definitions into `.cc` files
- Remove `using` statements from header files
- Make data fields of classes private
- Mark classes at the end of hierarchies as `final`

This is also partially being done in an attempt to avoid
a particular internal compiler error, see
#30475 (comment)
for details.

PR-URL: #30530
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
addaleax added a commit that referenced this pull request Nov 30, 2019
- Move inline functions into an `-inl.h` file
- Move override function definitions into `.cc` files
- Remove `using` statements from header files
- Make data fields of classes private
- Mark classes at the end of hierarchies as `final`

This is also partially being done in an attempt to avoid
a particular internal compiler error, see
#30475 (comment)
for details.

PR-URL: #30530
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this pull request Jan 13, 2020
- Move inline functions into an `-inl.h` file
- Move override function definitions into `.cc` files
- Remove `using` statements from header files
- Make data fields of classes private
- Mark classes at the end of hierarchies as `final`

This is also partially being done in an attempt to avoid
a particular internal compiler error, see
#30475 (comment)
for details.

PR-URL: #30530
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@targos
Copy link
Member

targos commented Jan 14, 2020

This needs a backport or other previous PRs to be backported in order to land on v12.x-staging.

@addaleax
Copy link
Member Author

@targos Yeah, removed the dont-land-on labels because I’m backporting this together with the remaining commit in #30551 – already working on it :)

addaleax added a commit to addaleax/node that referenced this pull request Jan 14, 2020
More precisely, make them untransferable if they were created through
*our* APIs, because those do not follow the improved free callback
mechanism that V8 uses now. All other ArrayBuffers can be transferred
between threads now, the assumption being that they were created in a
clean way that follows the V8 API on this.

This addresses a TODO comment.

Refs: nodejs#30339 (comment)

PR-URL: nodejs#30475
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
targos pushed a commit that referenced this pull request Jan 14, 2020
More precisely, make them untransferable if they were created through
*our* APIs, because those do not follow the improved free callback
mechanism that V8 uses now. All other ArrayBuffers can be transferred
between threads now, the assumption being that they were created in a
clean way that follows the V8 API on this.

This addresses a TODO comment.

Refs: #30339 (comment)

PR-URL: #30475
Backport-PR-URL: #31355
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
targos pushed a commit that referenced this pull request Jan 14, 2020
More precisely, make them untransferable if they were created through
*our* APIs, because those do not follow the improved free callback
mechanism that V8 uses now. All other ArrayBuffers can be transferred
between threads now, the assumption being that they were created in a
clean way that follows the V8 API on this.

This addresses a TODO comment.

Refs: #30339 (comment)

PR-URL: #30475
Backport-PR-URL: #31355
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
BethGriggs pushed a commit that referenced this pull request Feb 6, 2020
- Move inline functions into an `-inl.h` file
- Move override function definitions into `.cc` files
- Remove `using` statements from header files
- Make data fields of classes private
- Mark classes at the end of hierarchies as `final`

This is also partially being done in an attempt to avoid
a particular internal compiler error, see
#30475 (comment)
for details.

PR-URL: #30530
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
BethGriggs pushed a commit that referenced this pull request Feb 6, 2020
More precisely, make them untransferable if they were created through
*our* APIs, because those do not follow the improved free callback
mechanism that V8 uses now. All other ArrayBuffers can be transferred
between threads now, the assumption being that they were created in a
clean way that follows the V8 API on this.

This addresses a TODO comment.

Refs: #30339 (comment)

PR-URL: #30475
Backport-PR-URL: #31355
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Feb 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addons Issues and PRs related to native addons. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. buffer Issues and PRs related to the buffer subsystem. 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.

7 participants