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: fix assertion error in WeakCallback #3329

Closed
wants to merge 2 commits into from

Conversation

indutny
Copy link
Member

@indutny indutny commented Oct 12, 2015

CallbackInfo is now bound to ArrayBuffer instance, not Uint8Array,
therefore SPREAD_ARG will abort with:

Assertion failed: ((object)->IsUint8Array())

Make changes necessary to migrate it to ArrayBuffer.

See: #3080 (comment)

R=@trevnorris

`CallbackInfo` is now bound to `ArrayBuffer` instance, not `Uint8Array`,
therefore `SPREAD_ARG` will abort with:

    Assertion failed: ((object)->IsUint8Array())

Make changes necessary to migrate it to `ArrayBuffer`.

See: nodejs#3080 (comment)
@indutny indutny mentioned this pull request Oct 12, 2015
@indutny
Copy link
Member Author

indutny commented Oct 12, 2015

Local<ArrayBuffer> buf = object.As<ArrayBuffer>();
ArrayBuffer::Contents obj_c = buf->GetContents();
char* const obj_data = static_cast<char*>(obj_c.Data());
CHECK_NE(obj_data, nullptr);
Copy link
Contributor

Choose a reason for hiding this comment

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

@TooTallNate has mentioned how some use a zero-length buffer to keep track of things in their modules. A zero-length buffer would be nullptr. Instead should be like:

if (obj_c.Length() > 0) CHECK_NE(obj_data, nullptr);

Copy link
Contributor

Choose a reason for hiding this comment

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

might want to add a test for this case as well.

@trevnorris
Copy link
Contributor

Left 2 comments. Other than that, LGTM

@indutny
Copy link
Member Author

indutny commented Oct 12, 2015

@trevnorris fixed!

@trevnorris
Copy link
Contributor

LGTM

@indutny
Copy link
Member Author

indutny commented Oct 12, 2015

@mikemorris may I ask you to give a try to this patch? Does it fix problem for you?

@mscdex mscdex added the buffer Issues and PRs related to the buffer subsystem. label Oct 12, 2015
@mikemorris
Copy link

@indutny Looks like that fixed it, thanks for the quick response @indutny!

@indutny
Copy link
Member Author

indutny commented Oct 12, 2015

Great, thank you for confirming this! cc @jasnell

indutny added a commit that referenced this pull request Oct 13, 2015
`CallbackInfo` is now bound to `ArrayBuffer` instance, not `Uint8Array`,
therefore `SPREAD_ARG` will abort with:

    Assertion failed: ((object)->IsUint8Array())

Make changes necessary to migrate it to `ArrayBuffer`.

See: #3080 (comment)

Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trevor Norris <[email protected]>
PR-URL: #3329
@jasnell
Copy link
Member

jasnell commented Oct 13, 2015

Landed in 931118c

indutny added a commit that referenced this pull request Oct 13, 2015
`CallbackInfo` is now bound to `ArrayBuffer` instance, not `Uint8Array`,
therefore `SPREAD_ARG` will abort with:

    Assertion failed: ((object)->IsUint8Array())

Make changes necessary to migrate it to `ArrayBuffer`.

See: #3080 (comment)

Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trevor Norris <[email protected]>
PR-URL: #3329
@jasnell
Copy link
Member

jasnell commented Oct 13, 2015

Landed in v4.x in b3cbd13

@jasnell jasnell closed this Oct 13, 2015
jasnell added a commit that referenced this pull request Oct 13, 2015
* Includes fixes for two regressions
  - Assertion error in WeakCallback  - see [#3329](#3329)
  - Undefined timeout regression - see [#3331](#3331)
jasnell added a commit that referenced this pull request Oct 13, 2015
* Includes fixes for two regressions
  - Assertion error in WeakCallback  - see [#3329](#3329)
  - Undefined timeout regression - see [#3331](#3331)
jasnell added a commit that referenced this pull request Oct 13, 2015
* Includes fixes for two regressions
  - Assertion error in WeakCallback  - see [#3329](#3329)
  - Undefined timeout regression - see [#3331](#3331)

* Document an additional known issue with pipelined requests
  - See: #3332 and #3342
jasnell added a commit that referenced this pull request Oct 13, 2015
* Includes fixes for two regressions
  - Assertion error in WeakCallback  - see [#3329](#3329)
  - Undefined timeout regression - see [#3331](#3331)

* Document an additional known issue with pipelined requests
  - See: #3332 and #3342
jasnell added a commit that referenced this pull request Oct 13, 2015
* Includes fixes for two regressions
  - Assertion error in WeakCallback  - see [#3329](#3329)
  - Undefined timeout regression - see [#3331](#3331)

* Document an additional known issue with pipelined requests
  - See: #3332 and #3342
slice = null;
gc();
gc();
gc();
Copy link
Member

Choose a reason for hiding this comment

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

It's unclear to me why calling gc() three times is required here. @indutny Sorry to pull this up from more than 3 years ago, but do you remember why?

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.

7 participants