src: avoid truncating Blob sizes to 32 bits - #66207
Open
christianaurichzm wants to merge 1 commit into
Open
christianaurichzm wants to merge 1 commit into
christianaurichzm wants to merge 1 commit into
Conversation
Blob sizes cross between C++ and JavaScript as uint32 values, while the underlying DataQueue tracks them as uint64. openAsBlob() on a 5 GiB file therefore returned a Blob of size 1073741824. Reporting the real size is not enough on its own. The inbound direction assumes a uint32 as well, so a correct size reaches CHECK(IsUint32()) in ToSlice() and StoreDataObject() and aborts blob.slice() and URL.createObjectURL(). Pass the sizes as doubles and keep them as uint64_t in C++. Everything below this boundary is already 64-bit, so this only stops the narrowing at the edge. Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #66207 +/- ##
========================================
Coverage 90.29% 90.29%
========================================
Files 790 790
Lines 272529 272883 +354
Branches 52037 52111 +74
========================================
+ Hits 246074 246404 +330
- Misses 16908 16940 +32
+ Partials 9547 9539 -8
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Blob sizes cross between C++ and JavaScript as uint32 values, while the
underlying DataQueue tracks them as uint64. openAsBlob() on a 5 GiB file
therefore returned a Blob of size 1073741824.
Reporting the real size is not enough on its own. The inbound direction
assumes a uint32 as well, so a correct size reaches CHECK(IsUint32()) in
ToSlice() and StoreDataObject() and aborts blob.slice() and
URL.createObjectURL(). StoreDataObject() does not need openAsBlob() to be
reached, since an in-memory Blob is bounded by Uint8Array::kMaxLength
rather than by 4 GiB.
Pass the sizes as doubles and keep them as uint64_t in C++. Everything
below this boundary, FdEntry and FileHandle included, is already 64-bit,
so this only stops the narrowing at the edge. It also removes the
truncation on 32-bit platforms, where size_t was too narrow as well.
Fixes: #52585
Refs: #52588