WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED WONTFIX
260017
RangeError: Out of memory when creating (Shared)ArrayBuffer with big maxByteLength
https://bugs.webkit.org/show_bug.cgi?id=260017
Summary
RangeError: Out of memory when creating (Shared)ArrayBuffer with big maxByteL...
Joonas Lipping
Reported
2023-08-10 00:40:27 PDT
When creating an ArrayBuffer or SharedArrayBuffer with a small length but a large maxByteLength, for example: new ArrayBuffer(64 * 1024, { maxByteLength: 4 * 1024 * 1024 * 1024 }) or new SharedArrayBuffer(64 * 1024, { maxByteLength: 4 * 1024 * 1024 * 1024 }) a RangeError: Out of memory occurs, as if we are trying to allocate the whole 4GiB immediately. I would expect that the buffer would initially be created successfully with 64kiB of memory, but a subsequent grow() might fail, if it exceeds available memory. If I reduce the requested maxByteLength to e.g. 4MiB instead, it successfully creates the buffer. I think this only occurs if the device has less memory available than the maxByteLength that we give as an argument. On the iPhone SE (2020) that I have, the exception always occurs if I request maxByteLength as 4GiB, but on the laptop it's fine, presumably because the laptop has that much memory to spare.
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2023-08-17 00:41:12 PDT
<
rdar://problem/114012792
>
Mark Lam
Comment 2
2023-08-17 08:07:19 PDT
I don't think there's anything in the spec that says a device must give you the requested maxByteLength. There are many different constraints in a system as to why this is not workable. Does any other phone devices behave differently and allow a request for 4G of max capacity?
Yusuke Suzuki
Comment 3
2023-08-17 10:26:56 PDT
Yes, this is expected behavior. Growable DharedArrayBuffer is designed to allocate virtual memory region with maxByteLength (to allow concurrent access to grown memory), and this means that we need to allocate that from the beginning (the spec itself is designed so) So large size can fail, and expected.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug