Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(963)

Unified Diff: runtime/vm/parser.cc

Issue 2188863002: Force local context allocation in finally clauses (fixes #26948). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: work in progress Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/language/regress_26948_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index 9e7dcbd1018e1dc13c38c4658be6dc6e8392012b..9ba3baf0b5c5a10f0169cf9774d79e6a91fef066 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -9293,7 +9293,16 @@ SequenceNode* Parser::EnsureFinallyClause(
LocalVariable* rethrow_stack_trace_var) {
TRACE_PARSER("EnsureFinallyClause");
ASSERT(parse || (is_async && (try_stack_ != NULL)));
- OpenBlock();
+ // Increasing the loop level prevents the reuse of a parent context and forces
+ // the allocation of a local context to hold captured variables declared
+ // inside the finally clause. Otherwise, a captured variable gets allocated at
+ // different slots in the parent context each time the finally clause is
+ // reparsed, which is done to duplicate the ast. Since only one closure is
+ // kept due to canonicalization, it will access the correct slot in only one
+ // copy of the finally clause and the wrong slot in all others. By allocating
+ // a local context, all copies use the same slot in different local contexts.
+ // See issue #26948. This is a temporary fix until we eliminate reparsing.
zra 2016/07/27 21:07:23 DBC: Probably a good idea to go ahead and file an
regis 2016/07/27 21:27:09 Done. #26975
+ OpenLoopBlock();
if (parse) {
ExpectToken(Token::kLBRACE);
}
« no previous file with comments | « no previous file | tests/language/regress_26948_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698