Skip to content

Fix crash in UTF8ToString with resizable ArrayBuffers#27242

Open
heyparth1 wants to merge 1 commit into
emscripten-core:mainfrom
heyparth1:brutus/issue-27241
Open

Fix crash in UTF8ToString with resizable ArrayBuffers#27242
heyparth1 wants to merge 1 commit into
emscripten-core:mainfrom
heyparth1:brutus/issue-27241

Conversation

@heyparth1

Copy link
Copy Markdown

This fixes a crash in UTF8ToString (and related functions) that occurs when the heap is backed by a resizable ArrayBuffer. The TextDecoder.decode() API throws a TypeError when passed a view of a resizable ArrayBuffer, which previously caused a crash in builds with ALLOW_MEMORY_GROWTH and GROWABLE_ARRAYBUFFERS enabled.

The getUnsharedTextDecoderView function in src/parseTools.mjs is updated to detect when the heap might be resizable and generate code that copies the data using .slice() if the buffer is resizable, ensuring TextDecoder only receives non-resizable views. A test is added to verify this behavior by emulating the browser's strict TextDecoder implementation.

Closes #27241

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JS exception/crash in emsdk 6.0.2 when calling UTF8ToString

1 participant