Repository navigation
Conversation
Embedders can opt in so crossing JS_SetMemoryLimit is a host-visible termination that JavaScript cannot catch, including when no Error object can be allocated. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
|
What's the use case here? Can't the host app check the error and decide whether it allows the app to continue or stop it? |
Contributor
|
Use case: a host running untrusted scripts under a memory limit. The script can catch the out-of-memory error itself ( |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1773
JS_SetMemoryLimitTermination()opts in (off by default) so a rejection from the engine's ownJS_SetMemoryLimitcheck is a runtime-scoped terminal condition.null.catchdoes not resume, andJS_ExecutePendingJob()returns failure instead of running a rejection continuation.JS_GetTerminationStatus()reportsJS_TERMINATION_MEMORY_LIMITwithout parsing exception text.NULL, ordinary exceptions, and the previous catchable memory-limit behavior are unchanged. After termination the runtime is not reusable and should be freed.Test plan
api-testin Debug and ASan+UBSan, including catchable exhaustion, terminal sync (including 1-byte headroom /null), promise reaction, async resumption, promise constructor, thenable job, ordinary Error/RangeError/TypeError/syntax/rejection, custom-allocatorNULL, and a fresh runtimelre-testin Debug and ASan+UBSanrun-test262 -c tests.conf): 0/117 errors, 9 excluded, in Debug and ASan+UBSanctest,cxxtest, andjscheck(Apple Clang needs-Wno-unused-command-line-argumentforjscheck)JS_ABORT_ON_LEAKSviaapi-test; macOSleaks --atExitreported 0 leaksMade with Cursor