-
Notifications
You must be signed in to change notification settings - Fork 46
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
v8::internal::GlobalBackingStoreRegistry::Register: Check failed: result.second. #161
Comments
…nal empty buffer situation that parcel often generates, #161
…nal empty buffer situation that parcel often generates, #161
Thanks for the great test @mischnic . I think I have finally gotten to the bottom of this. I have long been puzzled by these errors since lmdb-js has plenty of unit tests for empty/zero-length buffers, but somehow parcel is able to generate some different/exotic variety of these that crashes node when getting address information for them. As it turns, the specific/minimum buffer that causes this issue of crashing node when attempting to get the address/size of a buffer is when there is more than one external buffer, with a zero length and that both point to the same non-null address and they are both accessed by getting their address/info. Of course this goes a little deeper than just lmdb-js. I am not exactly sure of the (implicit) expectations/invariants of external buffer address/sizes. Generally from what I have seen, if you create empty buffers through V8 that are given a null pointer as an address. I don't know if this is considered a requirement though. And it would seem that something in parcel (or rust) is probably creating an external zero-length buffer with a non-null address. And until there are multiple with the same address where more than one have contents that are accessed, it can get away with it. On the other hand, if this is indeed a legitimate use of external buffers, node should probably have an extra check for zero length buffers before calling GetBackingStore in https://github.com/nodejs/node/blob/master/src/js_native_api_v8.cc#L2924. I am not entirely sure which side to blame though, although I do think that since V8 version 8.x that multiple buffers are not allowed to have the same address (regardless of length, and they have assertions to this effect). Fortunately, the work around in lmdb-js is pretty trivial. I just check for zero length before getting the address. I have generally avoided this just to eliminate any extra overhead (and again, I don't think I should have to do this), but knowing this can only originate from externally allocated buffers, I can isolate this to a lesser-used branch. Anyway, thanks again for the great test case. I'll run my CI tests, and try to get an updated patch out shortly. |
Ok, fix published in v2.3.6. |
Thank you for the thorough investigation!
I think so too. |
Wow, nice job tracking back to napi-rs and putting together a fix, that's awesome! |
This should be fixed in Parcel with parcel-bundler/parcel#7995. And sorry for reporting this as an lmdb bug, when in reality Parcel simply passed you an invalid buffer 😄 |
parcel-bundler/parcel#7979 has introduced another one of these errors:
Reproduction (haven't found one without Parcel yet):
index.js:
package.json:
run
yarn build
The text was updated successfully, but these errors were encountered: