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

buffer: neuter external nullptr buffers #3624

Closed
wants to merge 1 commit into from

Conversation

indutny
Copy link
Member

@indutny indutny commented Nov 2, 2015

Neuter external nullptr buffers, otherwise their contents will be materialized on access, and the buffer instance will be internalized.

This leads to a crash like this:

v8::ArrayBuffer::Neuter Only externalized ArrayBuffers can be
neutered

Fix: #3619

cc @Trott @trevnorris

@Trott
Copy link
Member

Trott commented Nov 2, 2015

Fixes the issue for me. 👍

@Trott
Copy link
Member

Trott commented Nov 2, 2015

Not that you need help kicking of a CI job, but I did it anyway: https://ci.nodejs.org/job/node-test-pull-request/657/

@mscdex mscdex added the buffer Issues and PRs related to the buffer subsystem. label Nov 2, 2015
@indutny
Copy link
Member Author

indutny commented Nov 2, 2015

CI looks green, thank you @Trott

@indutny
Copy link
Member Author

indutny commented Nov 2, 2015

cc @nodejs/collaborators

I would like to get LGTM from either @trevnorris or @bnoordhuis before landing it.

@indutny
Copy link
Member Author

indutny commented Nov 2, 2015

btw, other reviews are more than welcome!

@trevnorris
Copy link
Contributor

LGTM

Would you consider this a v8 bug?

@@ -362,6 +362,8 @@ MaybeLocal<Object> New(Environment* env,
}

Local<ArrayBuffer> ab = ArrayBuffer::New(env->isolate(), data, length);
if (data == nullptr)
ab->Neuter();
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment explaining why the Neuter() call is necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, will do.

@bnoordhuis
Copy link
Member

LGTM with comments.

@@ -0,0 +1,7 @@
'use strict';
// Flags: --expose-gc
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this flag necessary here?

Copy link
Member

Choose a reason for hiding this comment

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

Yes. Without it, v8::Isolate::RequestGarbageCollectionForTesting() aborts with a run-time error.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok, didn't realize that

Neuter external `nullptr` buffers, otherwise their contents will be
materialized on access, and the buffer instance will be internalized.

This leads to a crash like this:

    v8::ArrayBuffer::Neuter Only externalized ArrayBuffers can be
    neutered

Fix: nodejs#3619
@indutny
Copy link
Member Author

indutny commented Nov 2, 2015

@trevnorris I'm not sure, maybe a documentation bug. Filed an issue: https://code.google.com/p/v8/issues/detail?id=4530

@indutny
Copy link
Member Author

indutny commented Nov 2, 2015

@nodejs/release how do I mark it to be landed on v5?

@indutny
Copy link
Member Author

indutny commented Nov 2, 2015

Landed in master in 827ee49, thank you everyone!

@indutny indutny closed this Nov 2, 2015
@indutny indutny deleted the fix/gh-3619 branch November 2, 2015 13:38
indutny added a commit that referenced this pull request Nov 2, 2015
Neuter external `nullptr` buffers, otherwise their contents will be
materialized on access, and the buffer instance will be internalized.

This leads to a crash like this:

    v8::ArrayBuffer::Neuter Only externalized ArrayBuffers can be
    neutered

Fix: #3619
PR-URL: #3624
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Trevor Norris <[email protected]>
@Trott
Copy link
Member

Trott commented Nov 2, 2015

I'm unable to find anything about who can propose releases and how, but is this a sufficiently significant bug/fix that a 5.0.1 release should happen as soon as is reasonable? Breaking nativescript and ffi seems significant to me, but I don't know what the agreed-upon litmus test (if any) is.

@trevnorris
Copy link
Contributor

Does this affect LTS?

@indutny
Copy link
Member Author

indutny commented Nov 2, 2015

@trevnorris nope, it just gets raw backing_store from the ArrayBuffer without materializing it. LTS is safe.

indutny added a commit that referenced this pull request Nov 7, 2015
Neuter external `nullptr` buffers, otherwise their contents will be
materialized on access, and the buffer instance will be internalized.

This leads to a crash like this:

    v8::ArrayBuffer::Neuter Only externalized ArrayBuffers can be
    neutered

Fix: #3619
PR-URL: #3624
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Trevor Norris <[email protected]>
@Fishrock123 Fishrock123 mentioned this pull request Nov 11, 2015
@rvagg rvagg mentioned this pull request Dec 17, 2015
addaleax added a commit to addaleax/node that referenced this pull request Jan 13, 2019
This call was introduced in 827ee49 to avoid a crash in a
later `Neuter()` call that has later been removed in ebbbc5a,
rendering the original call unnecessary.

Refs: nodejs#3624
Refs: nodejs#5204
addaleax added a commit that referenced this pull request Jan 21, 2019
This call was introduced in 827ee49 to avoid a crash in a
later `Neuter()` call that has later been removed in ebbbc5a,
rendering the original call unnecessary.

Refs: #3624
Refs: #5204

PR-URL: #25479
Reviewed-By: Anatoli Papirovski <[email protected]>
targos pushed a commit that referenced this pull request Jan 24, 2019
This call was introduced in 827ee49 to avoid a crash in a
later `Neuter()` call that has later been removed in ebbbc5a,
rendering the original call unnecessary.

Refs: #3624
Refs: #5204

PR-URL: #25479
Reviewed-By: Anatoli Papirovski <[email protected]>
BethGriggs pushed a commit that referenced this pull request Apr 29, 2019
This call was introduced in 827ee49 to avoid a crash in a
later `Neuter()` call that has later been removed in ebbbc5a,
rendering the original call unnecessary.

Refs: #3624
Refs: #5204

PR-URL: #25479
Reviewed-By: Anatoli Papirovski <[email protected]>
BethGriggs pushed a commit that referenced this pull request May 10, 2019
This call was introduced in 827ee49 to avoid a crash in a
later `Neuter()` call that has later been removed in ebbbc5a,
rendering the original call unnecessary.

Refs: #3624
Refs: #5204

PR-URL: #25479
Reviewed-By: Anatoli Papirovski <[email protected]>
MylesBorins pushed a commit that referenced this pull request May 16, 2019
This call was introduced in 827ee49 to avoid a crash in a
later `Neuter()` call that has later been removed in ebbbc5a,
rendering the original call unnecessary.

Refs: #3624
Refs: #5204

PR-URL: #25479
Reviewed-By: Anatoli Papirovski <[email protected]>
deepak1556 pushed a commit to electron/node that referenced this pull request Jul 10, 2019
This call was introduced in 827ee49 to avoid a crash in a
later `Neuter()` call that has later been removed in ebbbc5a,
rendering the original call unnecessary.

Refs: nodejs/node#3624
Refs: nodejs/node#5204

PR-URL: nodejs/node#25479
Reviewed-By: Anatoli Papirovski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
buffer Issues and PRs related to the buffer subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants