Version 2.12.4
* Cherry-pick bed058967673986153bfd965772c4032e706befe to stable
* Cherry-pick 83ed095505aa2209f3677ddb0d2d79fa8ffa1eeb to stable
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e2d2fb1..f4f9795 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,11 @@
-## 2.12.3 - 2021-04-12
+## 2.12.4 - 2021-04-15
+
+This is a patch release that fixes a Dart VM compiler crashes when compiling
+initializers containing async closures (issue [#45306][]).
+
+[#45306]: https://github.com/dart-lang/sdk/issues/45306
+
+## 2.12.3 - 2021-04-14
This is a patch release that fixes a vulnerability in `dart:html` related to
DOM clobbering. Thanks again to **Vincenzo di Cicco** for finding and reporting
diff --git a/runtime/tests/vm/dart/regress_45306_test.dart b/runtime/tests/vm/dart/regress_45306_test.dart
new file mode 100644
index 0000000..2b5e3c0
--- /dev/null
+++ b/runtime/tests/vm/dart/regress_45306_test.dart
@@ -0,0 +1,33 @@
+// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Regression test for https://github.com/dart-lang/sdk/issues/45306.
+// Verifies that ScopeBuilder doesn't crash on an async closure inside
+// instance field initializer.
+
+class X {
+ late final Y y = Y(
+ () async {},
+ );
+
+ final double? a;
+ final double? b;
+ final String? c;
+
+ X({
+ this.a,
+ this.b,
+ this.c,
+ });
+}
+
+typedef Callback = Future<void> Function();
+
+class Y {
+ Y(Callback? f);
+}
+
+void main() {
+ X();
+}
diff --git a/runtime/tests/vm/dart_2/regress_45306_test.dart b/runtime/tests/vm/dart_2/regress_45306_test.dart
new file mode 100644
index 0000000..36af440
--- /dev/null
+++ b/runtime/tests/vm/dart_2/regress_45306_test.dart
@@ -0,0 +1,33 @@
+// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Regression test for https://github.com/dart-lang/sdk/issues/45306.
+// Verifies that ScopeBuilder doesn't crash on an async closure inside
+// instance field initializer.
+
+class X {
+ final Y y = Y(
+ () async {},
+ );
+
+ final double a;
+ final double b;
+ final String c;
+
+ X({
+ this.a,
+ this.b,
+ this.c,
+ });
+}
+
+typedef Callback = Future<void> Function();
+
+class Y {
+ Y(Callback f);
+}
+
+void main() {
+ X();
+}
diff --git a/runtime/vm/compiler/frontend/scope_builder.cc b/runtime/vm/compiler/frontend/scope_builder.cc
index 11f7de3..ce41bb4 100644
--- a/runtime/vm/compiler/frontend/scope_builder.cc
+++ b/runtime/vm/compiler/frontend/scope_builder.cc
@@ -546,15 +546,6 @@
}
function_node_helper.SetJustRead(FunctionNodeHelper::kTypeParameters);
- // The :sync_op and :async_op continuations are called multiple times. So we
- // don't want the parameters from the first invocation to get stored in the
- // context and reused on later invocations with different parameters.
- if (function_node_helper.async_marker_ == FunctionNodeHelper::kSyncYielding) {
- for (intptr_t i = 0; i < function.NumParameters(); i++) {
- parsed_function_->ParameterVariable(i)->set_is_forced_stack();
- }
- }
-
// Read (but don't visit) the positional and named parameters, because they've
// already been added to the scope.
function_node_helper.ReadUntilExcluding(FunctionNodeHelper::kBody);
@@ -1537,7 +1528,11 @@
if (helper.IsCovariant()) {
variable->set_is_explicit_covariant_parameter();
}
- if (variable->name().ptr() == Symbols::IteratorParameter().ptr()) {
+
+ // The :sync_op and :async_op continuations are called multiple times. So we
+ // don't want the parameters from the first invocation to get stored in the
+ // context and reused on later invocations with different parameters.
+ if (current_function_async_marker_ == FunctionNodeHelper::kSyncYielding) {
variable->set_is_forced_stack();
}
diff --git a/tools/VERSION b/tools/VERSION
index 6f1acdf..194dc0e 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -26,6 +26,6 @@
CHANNEL stable
MAJOR 2
MINOR 12
-PATCH 3
+PATCH 4
PRERELEASE 0
PRERELEASE_PATCH 0
\ No newline at end of file