WebAssembly.Memory.grow() fails if WebAssembly.Memory was initialized with maximum memory as 4GB
Categories
(Core :: JavaScript: WebAssembly, defect)
Tracking
()
People
(Reporter: vdhawal, Unassigned)
Details
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.2 Safari/605.1.15
Steps to reproduce:
Sample code
#include "stdio.h"
#include "stdlib.h"
const int MB = 1024 * 1024;
int main() {
char* buf = malloc(12 * MB);
if (buf) {
printf("main completed\n");
} else {
printf("malloc failed in main\n");
}
return 0;
}
Emsdk version 2.0.0
Emscripten build command
emcc -g bug.c -s MAXIMUM_MEMORY=4GB -s ALLOW_MEMORY_GROWTH=1 -o index.html
opened index.html in various browsers
Actual results:
WebAssembly.Memory.grow() fails even when the total WASM memory would have been less than 2GB (which is the current supported limit on Firefox)
malloc Fails with Firefox 79.0
Works on Safari 13.1.2
Works on Chrome 84.0.4147.135
It happens because Emscripten generated code while initializing the WebAssembly.Memory passes 4GB.
Expected results:
Until the WebAssembly.memory is growing beyond 2GB (which is the current supported limit) WebAssembly.Memory.grow should be successful irrespective of the maximum_memory requests.
As per MDN the maximum_memory is just a hint and not an enforcement hence it should not affect invocation to memory.grow() as long as the the memory is not growing beyond the browser enforced limits
Comment 1•5 years ago
|
||
Bugbug thinks this bug should belong to this component, but please revert this change in case of error.
Updated•5 years ago
|
Description
•