Error stack GC finalizer: render only frame lines, add the name/message header at materialization - #302
Closed
robobun wants to merge 2 commits into
Closed
Error stack GC finalizer: render only frame lines, add the name/message header at materialization#302robobun wants to merge 2 commits into
robobun wants to merge 2 commits into
Conversation
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.
ErrorInstance::finalizeUnconditionally caches the stack string when captured frames die, through VM::onComputeErrorInfo, which cannot include the error name and message: the instance must not be read during the GC end phase (even an own-property lookup can re-materialize a property table, which allocates). The cached string began with a bare "Error" and a later .stack access served it as-is.
This adds VM::onComputeErrorInfoFrames, preferred over onComputeErrorInfo when set, with the contract that it renders only the frame lines. A new ErrorInstance bit records that the cached string needs a header, and materializeErrorInfoIfNeeded prepends sanitizedToString() when publishing it, where the instance is live and allocation is allowed. Nothing touches the instance inside the finalizer.
This also keeps the header lazy (a name assigned between the GC and the first .stack read is reflected, like the first-access path), and non-string name/message values render the same on both paths.
The existing callbacks keep their signatures and behavior; embedders that do not register the new callback are unaffected.
Needed for oven-sh/bun#34398.