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:
authorlegendecas <legendecas@gmail.com>2022-08-25 19:20:07 +0300
committerJuan José Arboleda <soyjuanarbol@gmail.com>2022-10-11 22:45:22 +0300
commit5355a46840e892cf3670925b202f8afa834fe0a5 (patch)
tree7cc13977de4ed162073aa75e09b90985c1d6c543 /src
parent2ba547aa5bbc854533133f072ed939040a62e1c9 (diff)
report: fix missing section javascriptHeap on OOMError
`Environment::GetCurrent` may not available in the context of OOM. Removes the cyclic `Environment::GetCurrent` and `env->isolate()` calls to ensure both `isolate` and `env` is present if available. However, this behavior is not guaranteed. As `Environment::GetCurrent` didn't allocate new handles in the heap, when a Context is entered it can still get the valid env pointer. Removes the unstable assertion of the absence of env in the test. 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_report.cc46
1 files changed, 28 insertions, 18 deletions
diff --git a/src/node_report.cc b/src/node_report.cc
index 3970f4ec531..38391300cda 100644
--- a/src/node_report.cc
+++ b/src/node_report.cc
@@ -784,21 +784,8 @@ static void PrintRelease(JSONWriter* writer) {
} // namespace report
-// External function to trigger a report, writing to file.
std::string TriggerNodeReport(Isolate* isolate,
- const char* message,
- const char* trigger,
- const std::string& name,
- Local<Value> error) {
- Environment* env = nullptr;
- if (isolate != nullptr) {
- env = Environment::GetCurrent(isolate);
- }
- return TriggerNodeReport(env, message, trigger, name, error);
-}
-
-// External function to trigger a report, writing to file.
-std::string TriggerNodeReport(Environment* env,
+ Environment* env,
const char* message,
const char* trigger,
const std::string& name,
@@ -868,10 +855,6 @@ std::string TriggerNodeReport(Environment* env,
compact = per_process::cli_options->report_compact;
}
- Isolate* isolate = nullptr;
- if (env != nullptr) {
- isolate = env->isolate();
- }
report::WriteNodeReport(
isolate, env, message, trigger, filename, *outstream, error, compact);
@@ -887,6 +870,33 @@ std::string TriggerNodeReport(Environment* env,
return filename;
}
+// External function to trigger a report, writing to file.
+std::string TriggerNodeReport(Isolate* isolate,
+ const char* message,
+ const char* trigger,
+ const std::string& name,
+ Local<Value> error) {
+ Environment* env = nullptr;
+ if (isolate != nullptr) {
+ env = Environment::GetCurrent(isolate);
+ }
+ return TriggerNodeReport(isolate, env, message, trigger, name, error);
+}
+
+// External function to trigger a report, writing to file.
+std::string TriggerNodeReport(Environment* env,
+ const char* message,
+ const char* trigger,
+ const std::string& name,
+ Local<Value> error) {
+ return TriggerNodeReport(env != nullptr ? env->isolate() : nullptr,
+ env,
+ message,
+ trigger,
+ name,
+ error);
+}
+
// External function to trigger a report, writing to a supplied stream.
void GetNodeReport(Isolate* isolate,
const char* message,