emscripten-core/emscripten
Ver no GitHubMEMFS crashes when writing large file
Open
#13.028 aberto em 13 de dez. de 2020
good first bughelp wantedwontfix
Métricas do repositório
- Stars
- (27.361 stars)
- Métricas de merge de PR
- (Mesclagem média 19d 10h) (147 fundiu PRs em 30d)
Description
Minimal example
// test.c
#include <stdio.h>
int main() {
FILE *fp = fopen("/tmp/test.txt", "w");
fseek(fp, 2147483647, SEEK_SET);
fputs("a", fp);
fclose(fp);
return 0;
}
Compiled with emcc with no options.
Actual behavior
Running this on firefox gives
RangeError: invalid array length
while running on Chromium gives
RangeError: Array buffer allocation failed
This happens when MEMFS tries to create a TypedArray that is too large.
Expected behavior
This should be treated as MEMFS running out of disk space and return appropriate errors to wasm.
See also #11381