Skip to content

Throw out of memory when JS_ReadObjectAtoms() cannot allocate an atom - #1976

Open
cognitivegears wants to merge 2 commits into
quickjs-ng:masterfrom
cognitivegears:fix-lazy-builtin-oom
Open

cognitivegears wants to merge 2 commits into
quickjs-ng:masterfrom
cognitivegears:fix-lazy-builtin-oom

Conversation

@cognitivegears

Copy link
Copy Markdown

Under a memory limit, the first access to Array.fromAsync, Iterator.zip or Iterator.zipKeyed can fail in JS_ReadObjectAtoms() with nothing thrown, so a catch clause gets JS_UNINITIALIZED. This is the engine's built-in bytecode, reached from ordinary source. It now throws out of memory when __JS_NewAtom() fails.

Also frees js_bytecode_eval()'s arguments on failure, as in TelegramMessenger/quickjs@8ceed75 (John Preston); the test trips that leak otherwise. The test needs #1975 first, so this branch is on top of it.

Refs #1917

(Drafted with AI assistance.)

When resize_properties() can't grow a shape's property table,
js_realloc() throws while the shape is off gc_obj_list. Creating the
error can run the GC, which then calls list_del() on the unlinked
shape.

Reallocate with js_realloc_rt() and throw after relinking.

Refs: quickjs-ng#1917
Under a memory limit, the first access to Array.fromAsync,
Iterator.zip or Iterator.zipKeyed can fail in JS_ReadObjectAtoms()
with nothing thrown, so a catch clause gets JS_UNINITIALIZED. Throw
out of memory when __JS_NewAtom() fails.

Also free js_bytecode_eval()'s arguments on failure, as in
TelegramMessenger/quickjs@8ceed75 (John Preston); the test trips
that leak otherwise.

This branch has not been deployed

No deployments
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.

1 participant