diff options
author | legendecas <legendecas@gmail.com> | 2022-08-25 19:20:07 +0300 |
---|---|---|
committer | legendecas <legendecas@gmail.com> | 2022-09-02 09:01:39 +0300 |
commit | 7f496fefb67c6a9ad22db87eb69104e9a9abb6d2 (patch) | |
tree | a43d0cc6ff19ee52ff1c27abc6d99b39f924ac96 /src | |
parent | d0f73d383d5e1ed58c96a272036744d4bed22b8f (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.cc | 46 |
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, |