Skip to content

Commit

Permalink
False positive on OOM error (#212)
Browse files Browse the repository at this point in the history
gc callback can happen between init and set
this causes a confusing OOM crash because max mem is 0 at this point, so if the callback is hit, then the isolate will terminate no matter what.

Co-authored-by: nightpool <nightpool@users.noreply.github.com>
  • Loading branch information
seanmakesgames and nightpool committed Jul 6, 2021
1 parent 7de7a90 commit 50c3664
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions ext/mini_racer_extension/mini_racer_extension.cc
Expand Up @@ -467,6 +467,14 @@ nogvl_context_eval(void* arg) {

IsolateData::Init(isolate);

if (eval_params->max_memory > 0) {
IsolateData::Set(isolate, IsolateData::MEM_SOFTLIMIT_MAX, eval_params->max_memory);
if (!isolate_info->added_gc_cb) {
isolate->AddGCEpilogueCallback(gc_callback);
isolate_info->added_gc_cb = true;
}
}

MaybeLocal<Script> parsed_script;

if (eval_params->filename) {
Expand All @@ -491,14 +499,6 @@ nogvl_context_eval(void* arg) {
result->message->Reset(isolate, trycatch.Exception());
} else {
// parsing successful
if (eval_params->max_memory > 0) {
IsolateData::Set(isolate, IsolateData::MEM_SOFTLIMIT_MAX, eval_params->max_memory);
if (!isolate_info->added_gc_cb) {
isolate->AddGCEpilogueCallback(gc_callback);
isolate_info->added_gc_cb = true;
}
}

if (eval_params->marshal_stackdepth > 0) {
StackCounter::SetMax(isolate, eval_params->marshal_stackdepth);
}
Expand Down

0 comments on commit 50c3664

Please sign in to comment.