Skip to content

buffer: FreeCallback should be tied to ArrayBuffer - #3198

Closed
indutny wants to merge 1 commit into
nodejs:masterfrom
indutny:fix/buffer-wrong-free-callback-handle
Closed

buffer: FreeCallback should be tied to ArrayBuffer#3198
indutny wants to merge 1 commit into
nodejs:masterfrom
indutny:fix/buffer-wrong-free-callback-handle

Conversation

@indutny

Copy link
Copy Markdown
Member

FreeCallback should be invoked on the storage disposal (ArrayBuffer),
not when the view (Uint8Array or Buffer) is disposed. This causes
bug and crashes in addons which create buffers and store only slices of
them.

cc @trevnorris@bnoordhuis @nodejs/collaborators

@indutny

Copy link
Copy Markdown
MemberAuthor

@bnoordhuis I wonder if it may be a good opportunity to write our first C++ test.

@Fishrock123Fishrock123 added the buffer Issues and PRs related to the buffer subsystem. label Oct 6, 2015
@indutny
indutnyforce-pushed the fix/buffer-wrong-free-callback-handle branch from 21c3543 to 1ce1e17CompareOctober 6, 2015 04:30
@indutny

Copy link
Copy Markdown
MemberAuthor

Nah, gtest didn't work out. It was simpler to just write an test addon.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, is it viable to use a technique similar to https://groups.google.com/d/msg/v8-users/JmhzmswiqvM/IC6UtV5FEC4J so that --expose-gc doesn't have to be passed?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

idk, seems to be a legit use of RequestGC here

@trevnorris

Copy link
Copy Markdown
Contributor

LGTM. Does CI run these tests?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can I suggest you make this a counter and check that it's > 0 in FreeCallback?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Sure.

@bnoordhuis

Copy link
Copy Markdown
Member

LGTM

FreeCallback should be invoked on the storage disposal (`ArrayBuffer`),
not when the view (`Uint8Array` or `Buffer`) is disposed. This causes
bug and crashes in addons which create buffers and store only slices of
them.
PR-URL: nodejs#3198
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
@indutny
indutnyforce-pushed the fix/buffer-wrong-free-callback-handle branch from 1ce1e17 to 9d4063eCompareOctober 6, 2015 17:37
@indutny

Copy link
Copy Markdown
MemberAuthor

All fixed and rebased. Running CI.

@indutny

Copy link
Copy Markdown
MemberAuthor

@indutny

Copy link
Copy Markdown
MemberAuthor

Landed in d1f2404, please backport to v4.x

indutny added a commit that referenced this pull request Oct 6, 2015
FreeCallback should be invoked on the storage disposal (`ArrayBuffer`),
not when the view (`Uint8Array` or `Buffer`) is disposed. This causes
bug and crashes in addons which create buffers and store only slices of
them.
PR-URL: #3198
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
@indutnyindutny closed this Oct 6, 2015
@indutny
indutny deleted the fix/buffer-wrong-free-callback-handle branch October 6, 2015 22:58
@jasnelljasnell mentioned this pull request Oct 8, 2015
29 tasks
indutny added a commit that referenced this pull request Oct 8, 2015
FreeCallback should be invoked on the storage disposal (`ArrayBuffer`),
not when the view (`Uint8Array` or `Buffer`) is disposed. This causes
bug and crashes in addons which create buffers and store only slices of
them.
PR-URL: #3198
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
@MylesBorins

Copy link
Copy Markdown
Contributor

landed in v4.x-staging in 660f759

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bufferIssues and PRs related to the buffer subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@indutny@trevnorris@bnoordhuis@MylesBorins@jasnell@Fishrock123