Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChengzhong Wu <chengzhong.wcz@alibaba-inc.com>2022-08-26 09:09:05 +0300
committerJuan José Arboleda <soyjuanarbol@gmail.com>2022-10-11 22:45:22 +0300
commit0e2c2064bbfa9fb5806a023f9fd8f8c9ca4d4fc5 (patch)
treeee462a80b5991faf4bb22a11539cd46e8ed8d50e /src
parent5355a46840e892cf3670925b202f8afa834fe0a5 (diff)
report: get stack trace with cross origin contexts
When a new context with a different security token is entered, or when no context is entered, `StackTrace::CurrentStackTrace` need to be explicitly set with flag `kExposeFramesAcrossSecurityOrigins` to avoid crashing. PR-URL: https://github.com/nodejs/node/pull/44398 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/node_errors.cc5
-rw-r--r--src/node_report.cc6
2 files changed, 10 insertions, 1 deletions
diff --git a/src/node_errors.cc b/src/node_errors.cc
index bfc93ec70d2..0bba6e5e1f2 100644
--- a/src/node_errors.cc
+++ b/src/node_errors.cc
@@ -471,6 +471,11 @@ void OOMErrorHandler(const char* location, bool is_heap_oom) {
}
if (report_on_fatalerror) {
+ // Trigger report with the isolate. Environment::GetCurrent may return
+ // nullptr here:
+ // - If the OOM is reported by a young generation space allocation,
+ // Isolate::GetCurrentContext returns an empty handle.
+ // - Otherwise, Isolate::GetCurrentContext returns a non-empty handle.
TriggerNodeReport(isolate, message, "OOMError", "", Local<Object>());
}
diff --git a/src/node_report.cc b/src/node_report.cc
index 38391300cda..bf37e24d09c 100644
--- a/src/node_report.cc
+++ b/src/node_report.cc
@@ -470,8 +470,12 @@ static void PrintJavaScriptStack(JSONWriter* writer,
void* samples[MAX_FRAME_COUNT];
isolate->GetStackSample(state, samples, MAX_FRAME_COUNT, &info);
+ constexpr StackTrace::StackTraceOptions stack_trace_options =
+ static_cast<StackTrace::StackTraceOptions>(
+ StackTrace::kDetailed |
+ StackTrace::kExposeFramesAcrossSecurityOrigins);
Local<StackTrace> stack = StackTrace::CurrentStackTrace(
- isolate, MAX_FRAME_COUNT, StackTrace::kDetailed);
+ isolate, MAX_FRAME_COUNT, stack_trace_options);
if (stack->GetFrameCount() == 0) {
PrintEmptyJavaScriptStack(writer);