You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The VM sometimes keep unrelated memory alive when it constructs non-capturing closures.
When the parser detects that a closure doesn't have any free variables it avoids the context creation, but accidentally reuses the one that was passed in, which could hold onto random objects.
Dart2js, for example, held onto the main-compilation object (which basically meant almost everything) and ran out of memory.
Our batch-mode (halving the compilation time on the build-bot) is blocked by this bug, so I'm assigning priority high to it.
We could work around it, though. If fixing it turns out to be difficult let us know and we will implement the work-around.
With the following patch dart2js runs without oom:
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index 66018e5..e54cf32 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -185,7 +185,7 @@ void ParsedFunction::AllocateVariables() {
// had the effect of unintentionally retaining parent contexts which
// would never be accessed. By breaking the context chain at this
// point, we allow these outer contexts to be collected.
if (found_captured_variables) {
if (true || found_captured_variables) {
const ContextScope& context_scope =
ContextScope::Handle(function().context_scope());
if (context_scope.IsNull() || (context_scope.num_variables() == 0)) {
diff --git a/runtime/vm/flow_graph_type_propagator.cc b/runtime/vm/flow_graph_type_propagator.cc
index d2c72bd..84356cf 100644
I am having a hard time figuring out what pattern you are referring to that keeps objects alive which should not be alive any longer. Can you please provide an example?
main() {
var closure = null;
do {
closure = bar(closure, new List(1024 * 1024));
} while (true);
}
will crash with OOM because the context of f allocated within bar is actually leaking and becoming the context of empty non-capturing closure allocated inside foo. If we declare foo like this instead:
The VM sometimes keep unrelated memory alive when it constructs non-capturing closures.
When the parser detects that a closure doesn't have any free variables it avoids the context creation, but accidentally reuses the one that was passed in, which could hold onto random objects.
Dart2js, for example, held onto the main-compilation object (which basically meant almost everything) and ran out of memory.
Our batch-mode (halving the compilation time on the build-bot) is blocked by this bug, so I'm assigning priority high to it.
We could work around it, though. If fixing it turns out to be difficult let us know and we will implement the work-around.
With the following patch dart2js runs without oom:
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index 66018e5..e54cf32 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -185,7 +185,7 @@ void ParsedFunction::AllocateVariables() {
// had the effect of unintentionally retaining parent contexts which
// would never be accessed. By breaking the context chain at this
// point, we allow these outer contexts to be collected.
const ContextScope& context_scope =
ContextScope::Handle(function().context_scope());
if (context_scope.IsNull() || (context_scope.num_variables() == 0)) {
diff --git a/runtime/vm/flow_graph_type_propagator.cc b/runtime/vm/flow_graph_type_propagator.cc
index d2c72bd..84356cf 100644
--- a/runtime/vm/flow_graph_type_propagator.cc
+++ b/runtime/vm/flow_graph_type_propagator.cc
@@ -552,6 +552,9 @@ const AbstractType* CompileType::ToAbstractType() {
if (cid_ == kFunctionCid) {
type_ = &Type::ZoneHandle(Type::DynamicType());
return type_;
The text was updated successfully, but these errors were encountered: