AssemblyScript / assemblyscript

A TypeScript-like language for WebAssembly.
https://www.assemblyscript.org
Apache License 2.0
16.6k stars 650 forks source link

as crash when try to alloc large data #2827

Open HerrCai0907 opened 3 months ago

HerrCai0907 commented 3 months ago

Bug description

AS compiler crash after hang up a few second.

Steps to reproduce

memory.data(0x7fffffff);

npm run asbuild:debug

AssemblyScript version

v0.27.x

CountBleck commented 3 months ago

It looks like most of the time is spent in the allocU8Array call here, but the exception (a simple number, like 2153016872) is thrown in the binaryen._BinaryenSetMemory call without any delay there. I'll look into it a bit more.

CountBleck commented 3 months ago

Hm, I can only guess that it has something to do with the copy here, since binaryen.js's memory might hit the 4 GiB limit there.