-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
WASM build can crash with "RuntimeError Index out of bounds" when converting UTF-16LE text to UTF8 #11
Comments
Possibly related to rustwasm/wasm-pack#479 |
Set examples/.cargo/config.toml to create an 8 Mb stack rather than the default 1 Mb, as per rustwasm/wasm-pack#479. Confirmed 8 Mb stack size applied correctly using wasm2wat tool. RuntimeError continues. Used debug profile to confirm problem occurs in the following WASM instruction:
inside the compiled drop_in_place() calls a stack of functions that ultimately end up inside the memory allocator. |
The actual error occurs in |
Changing the allocator to |
Growing the module heap using Forcing Rust to avoid freeing the byte buffer via I need better disassembly in order to diagnose exactly what values are triggering the out of bounds error. |
Well, the stack frame sizing turned out to be a red herring after all. It was the error during the drop_in_place() deallocation that should have given the big hint: a buffer was being allocated with the wrong buffer length. It turned out that the call to |
Removed resizing of stack frame in examples/.cargo/config.toml, as it was never the problem. Reset default allocator from wee-alloc to dlmalloc. Removed explicit heap memory growth in Javascript. Corrected error in |
Follow-on from #10. The examples/objects sample, when compiled to WASM and run in the browser, will crash with a
RuntimeError Index out of bounds
during text conversion. Strangely, this appears to be happening when attempting to return a value fromutils::get_string_from_pdfium_utf16le_bytes()
, which may suggest an out-of-memory problem with the stack frame sizing in the default WASM compile settings.The text was updated successfully, but these errors were encountered: