Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions api-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1085,8 +1085,14 @@ static void large_allocation_accounting(void)
JS_ComputeMemoryUsage(rt, &before);
JS_SetMemoryLimit(rt, (size_t)before.malloc_size + 4 * block_size);
ret = eval(ctx, "globalThis.a = [];\n"
"for (let i = 0; i < 64; i++)\n"
" a.push(new Uint8Array(1024 * 1024));");
"for (let i = 0; i < 64; i++) {\n"
" // OOM exception should be uncatchable\n"
" try {\n"
" a.push(new Uint8Array(1024 * 1024));"
" } catch (e) {\n"
" throw 'unexpected exception';\n"
" }\n"
"}");
assert(JS_IsException(ret));
JS_SetMemoryLimit(rt, 0);
JS_ComputeMemoryUsage(rt, &after);
Expand Down
3 changes: 2 additions & 1 deletion quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -8563,6 +8563,7 @@ JSValue JS_ThrowOutOfMemory(JSContext *ctx)
if (!rt->in_out_of_memory) {
rt->in_out_of_memory = true;
JS_ThrowInternalError(ctx, "out of memory");
JS_SetUncatchableError(ctx, ctx->rt->current_exception);
rt->in_out_of_memory = false;
}
return JS_EXCEPTION;
Expand Down Expand Up @@ -49781,7 +49782,7 @@ static JSValue js_regexp_exec(JSContext *ctx, JSValueConst this_val,
JS_ThrowInterrupted(ctx);
break;
case LRE_RET_MEMORY_ERROR:
JS_ThrowInternalError(ctx, "out of memory in regexp execution");
JS_ThrowOutOfMemory(ctx);
break;
case LRE_RET_BYTECODE_ERROR:
JS_ThrowInternalError(ctx, "corrupted bytecode in regexp execution");
Expand Down
Loading