diff --git a/Source/JavaScriptCore/runtime/ErrorInstance.cpp b/Source/JavaScriptCore/runtime/ErrorInstance.cpp index 0f090b58c1e95..ae122859be500 100644 --- a/Source/JavaScriptCore/runtime/ErrorInstance.cpp +++ b/Source/JavaScriptCore/runtime/ErrorInstance.cpp @@ -396,7 +396,7 @@ void ErrorInstance::computeErrorInfo(VM& vm, bool allocationAllowed) if (m_stackPropertyAlreadyMaterialized) stackString = emptyString(); else - stackString = fn(vm, *m_stackTrace.get(), m_lineColumn.line, m_lineColumn.column, m_sourceURL, this->bunErrorData()); + stackString = fn(vm, *m_stackTrace.get(), m_lineColumn.line, m_lineColumn.column, m_sourceURL, this, this->bunErrorData()); } else { getLineColumnAndSource(vm, m_stackTrace.get(), m_lineColumn, m_sourceURL); // If the stack property was already materialized by Error.captureStackString, diff --git a/Source/JavaScriptCore/runtime/VM.h b/Source/JavaScriptCore/runtime/VM.h index cf23d183cee9d..0709cec3af9c5 100644 --- a/Source/JavaScriptCore/runtime/VM.h +++ b/Source/JavaScriptCore/runtime/VM.h @@ -173,7 +173,11 @@ constexpr bool validateDFGDoesGC = ENABLE_DFG_DOES_GC_VALIDATION; #if USE(BUN_JSC_ADDITIONS) using StackTraceAppenderFunction = WTF::Function& stackTrace, size_t maxToAppend)>; -using ErrorInfoFunction = WTF::Function& stackTrace, unsigned& line, unsigned& column, String& sourceURL, void* bunErrorData)>; +// Called by ErrorInstance::computeErrorInfo. Its main caller is ErrorInstance::reconcileWeakReferencesAtGCEnd, +// which runs inside Heap::runEndPhase when a frame of a not yet materialized stack trace died; the returned +// string then becomes the error's final .stack. errorInstance is the error being formatted, so the embedder +// can still put its name and message on the first line. The function must not allocate GC cells or run JS. +using ErrorInfoFunction = WTF::Function& stackTrace, unsigned& line, unsigned& column, String& sourceURL, JSC::JSObject* errorInstance, void* bunErrorData)>; using ErrorInfoFunctionJSValue = WTF::Function& stackTrace, unsigned& line, unsigned& column, String& sourceURL, JSC::JSObject*, void* bunErrorData)>; #endif