-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Conversation
`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)
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); |
There was a problem hiding this comment.
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);
There was a problem hiding this comment.
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.
Left 2 comments. Other than that, LGTM |
@trevnorris fixed! |
LGTM |
@mikemorris may I ask you to give a try to this patch? Does it fix problem for you? |
Great, thank you for confirming this! cc @jasnell |
`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 <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> PR-URL: #3329
Landed in 931118c |
`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 <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> PR-URL: #3329
Landed in v4.x in b3cbd13 |
slice = null; | ||
gc(); | ||
gc(); | ||
gc(); |
There was a problem hiding this comment.
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?
CallbackInfo
is now bound toArrayBuffer
instance, notUint8Array
,therefore
SPREAD_ARG
will abort with:Make changes necessary to migrate it to
ArrayBuffer
.See: #3080 (comment)
R=@trevnorris