Closed Bug 1674777 Opened 4 years ago Closed 4 years ago

Audit JSAPI and add jsapi-tests for large ArrayBuffers

Categories

(Core :: JavaScript Engine, task, P3)

task

Tracking

()

RESOLVED FIXED
87 Branch
Tracking Status
firefox87 --- fixed

People

(Reporter: jandem, Assigned: jandem)

References

Details

Attachments

(13 files)

(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details

This is not the most urgent thing to address for bug 1673557, but we should ensure we have proper tests for this eventually.

Especially the APIs that don't go through the internal accessors are easy to overlook in an audit.

A later patch will add a jsapi-test for this.

Assignee: nobody → jdemooij
Status: NEW → ASSIGNED

Depends on D103273

Of these four, only JS_GetTypedArrayByteLength is used outside jsapi-tests.

Keywords: leave-open
Pushed by jdemooij@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/d55cbd2be32d
part 1 - Change JS::NewArrayBuffer and JS_New*Array size argument from uint32_t to size_t. r=sfink
https://hg.mozilla.org/integration/autoland/rev/f330737adc50
part 2 - Enable large ArrayBuffers for jsapi-tests. r=sfink
https://hg.mozilla.org/integration/autoland/rev/5539557bbfd3
part 3 - Change Get*LengthAndData outparam from uint32_t to size_t. r=sfink,aosmond
https://hg.mozilla.org/integration/autoland/rev/94684c2cfbc4
part 4 - Change some JSAPI byteLength and byteOffset accessors to return size_t instead of uint32_t. r=sfink

Note that in the IndexedDB code we pass a Span to Key::EncodeAsString where we check
for large lengths.

There's only one caller outside jsapi-tests so these are easy to convert.

Depends on D103679

Pushed by jdemooij@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/b142ae1ffe74
part 5 - Change GetObjectAs* APIs to use size_t for outparam instead of uint32_t. r=sfink,sg

We're adding support for ArrayBuffers larger than 4 GB to the JS engine (on 64-bit
platforms).

ReadArrayBuffer uses uint32_t values in a number of places. This patch ensures we
throw an exception for code like this: stream.readArrayBuffer(ab.byteLength, ab, ...)).

Similar to the previous patch. Prevent truncation when assigning to mBufferLength.

Depends on D103759

Note that previous patches already fixed various other callers.

Depends on D103760

Attachment #9200631 - Attachment description: Bug 1674777 part 7 - Change nsIBinaryInputStream.readArrayBuffer aLength argument from uint32_t to uint64_t. r?kmag! → Bug 1674777 part 7 - Change nsIBinaryInputStream.readArrayBuffer to use uint64_t instead of uint32_t. r?kmag!

For enumerateNames on Xrays, throw an OOM exception upfront. This matches what we do
inside the JS engine when enumerating large typed arrays.

The callers in AudioWorkletNode.cpp are just comparing the length to the expected length
to guard against detachment.

Depends on D103902

Also change wasmMaxSize and wasmMappedSize to use 'get' instead of 'deprecatedGetUint32'.

Pushed by jdemooij@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/d4bd35d3c25d
part 6 - Change SharedArrayBuffer APIs to use size_t instead of uint32_t. r=lth
Blocks: 1691882
Pushed by jdemooij@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/031bc0b1e8e5
part 7 - Change nsIBinaryInputStream.readArrayBuffer to use uint64_t instead of uint32_t. r=kmag
https://hg.mozilla.org/integration/autoland/rev/e23dca0763fc
part 8 - Change nsIArrayBufferInputStream.setData arguments from uint32_t to uint64_t. r=kmag
https://hg.mozilla.org/integration/autoland/rev/42239f7a0ddf
part 9 - Change GetArrayBufferByteLength return type from uint32_t to size_t. r=sfink
Pushed by jdemooij@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/03c71d1fa7f8
part 10 - Fix XPConnect callers for JS_GetTypedArrayLength returning size_t. r=kmag
https://hg.mozilla.org/integration/autoland/rev/ce348dc69837
part 11 - Change JS_GetTypedArrayLength return type from uint32_t to size_t. r=sfink
https://hg.mozilla.org/integration/autoland/rev/a5b7b61ae148
part 12 - Add test for XPConnect array conversions involving large typed arrays. r=kmag
https://hg.mozilla.org/integration/autoland/rev/f34c46915ae1
part 13 - Remove deprecatedGetUint32. r=lth
Keywords: leave-open
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 87 Branch
Regressions: 1692006
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: