Repository navigation
[pull] main from oven-sh:main - #10
Merged
Merged
Conversation
…cript prototype host functions (#328) Every host function in JSInjectedScriptHostPrototype.cpp and JSJavaScriptCallFramePrototype.cpp declares a ThrowScope (for the dynamicDowncast type error) and then tail-calls into a JSInjectedScriptHost / JSJavaScriptCallFrame member that itself declares a ThrowScope. Under validateExceptionChecks=1 this aborts with 'Unchecked JS exception' because the outer scope is never released before the inner one is created. Observed in Bun with any Runtime.evaluate over an inspector connection: ERROR: Unchecked JS exception: This scope can throw a JS exception: evaluateWithScopeExtension @ JSInjectedScriptHost.cpp:120 But the exception was unchecked as of this scope: jsInjectedScriptHostPrototypeFunctionEvaluateWithScopeExtension @ JSInjectedScriptHostPrototype.cpp:275 Wrap every tail return in RELEASE_AND_RETURN(scope, ...) so the outer scope is released before the callee may create its own.
…ue (#317) * LiteralParser: throw RangeError on OOM when copying a JSON string value JSONAtomStringCache::makeJSString called String(characters) for string values longer than 16 chars. That constructor goes through StringImpl::createUninitializedInternalNonEmpty -> StringImplMalloc::malloc, which is the crash-or-succeed allocator. Parsing a JSON string value that cannot be allocated killed the process. Use StringImpl::tryCreateUninitialized and surface a null result up through LiteralParser::parsePrimitiveValue, which now throws the same RangeError: Out of memory that String.prototype.repeat and friends throw. * Rename makeJSString to tryMakeJSString Follows the JSC convention of prefixing try- on functions that return nullptr on allocation failure (tryCreateUninitialized, tryMakeString).
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )
Summary by cubic
Fixes exception-scope handling in inspector host functions to stop “Unchecked JS exception” aborts during Runtime.evaluate. Hardens JSON parsing to fail gracefully on long-string OOM by throwing a RangeError instead of crashing.
JSInjectedScriptHostPrototype.cppandJSJavaScriptCallFramePrototype.cppusing RELEASE_AND_RETURN(scope, ...), preventing false “Unchecked JS exception” undervalidateExceptionChecks=1.StringImpl::tryCreateUninitialized; failures return nullptr viatryMakeJSStringand surface inLiteralParser::parsePrimitiveValue, which now throws “RangeError: Out of memory.”Written for commit 1acceb9. Summary will update on new commits.