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

Side by Side Diff: runtime/vm/isolate.cc

Issue 2159923003: Fix use-after-free in isolate reload. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/isolate.h" 5 #include "vm/isolate.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/text_buffer.h" 10 #include "platform/text_buffer.h"
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 delete reload_context_; 1088 delete reload_context_;
1089 reload_context_ = NULL; 1089 reload_context_ = NULL;
1090 } 1090 }
1091 1091
1092 1092
1093 void Isolate::ReloadSources(bool test_mode) { 1093 void Isolate::ReloadSources(bool test_mode) {
1094 ASSERT(!IsReloading()); 1094 ASSERT(!IsReloading());
1095 has_attempted_reload_ = true; 1095 has_attempted_reload_ = true;
1096 reload_context_ = new IsolateReloadContext(this, test_mode); 1096 reload_context_ = new IsolateReloadContext(this, test_mode);
1097 reload_context_->StartReload(); 1097 reload_context_->StartReload();
1098 delete reload_context_;
1099 reload_context_ = NULL;
1098 } 1100 }
1099 #endif // !PRODUCT 1101 #endif // !PRODUCT
1100 1102
1101 1103
1102 void Isolate::DoneFinalizing() { 1104 void Isolate::DoneFinalizing() {
1103 NOT_IN_PRODUCT( 1105 NOT_IN_PRODUCT(
1104 if (IsReloading()) { 1106 if (IsReloading()) {
1105 reload_context_->FinishReload(); 1107 reload_context_->FinishReload();
1106 if (reload_context_->has_error() && reload_context_->test_mode()) { 1108 if (reload_context_->has_error() && reload_context_->test_mode()) {
1107 // If the reload has an error and we are in test mode keep the reload 1109 // If the reload has an error and we are in test mode keep the reload
1108 // context on the isolate so that it can be used by unit tests. 1110 // context on the isolate so that it can be used by unit tests.
1109 return; 1111 return;
1110 } 1112 }
1111 if (reload_context_->has_error()) { 1113 if (reload_context_->has_error()) {
1112 // Remember the reload error. 1114 // Remember the reload error.
1113 sticky_reload_error_ = reload_context_->error(); 1115 sticky_reload_error_ = reload_context_->error();
1114 } 1116 }
1115 if (!reload_context_->has_error()) { 1117 if (!reload_context_->has_error()) {
1116 reload_context_->ReportSuccess(); 1118 reload_context_->ReportSuccess();
1117 } 1119 }
1118 delete reload_context_;
1119 reload_context_ = NULL;
1120 } 1120 }
1121 ) 1121 )
1122 } 1122 }
1123 1123
1124 1124
1125 1125
1126 bool Isolate::MakeRunnable() { 1126 bool Isolate::MakeRunnable() {
1127 ASSERT(Isolate::Current() == NULL); 1127 ASSERT(Isolate::Current() == NULL);
1128 1128
1129 MutexLocker ml(mutex_); 1129 MutexLocker ml(mutex_);
(...skipping 1744 matching lines...) Expand 10 before | Expand all | Expand 10 after
2874 void IsolateSpawnState::DecrementSpawnCount() { 2874 void IsolateSpawnState::DecrementSpawnCount() {
2875 ASSERT(spawn_count_monitor_ != NULL); 2875 ASSERT(spawn_count_monitor_ != NULL);
2876 ASSERT(spawn_count_ != NULL); 2876 ASSERT(spawn_count_ != NULL);
2877 MonitorLocker ml(spawn_count_monitor_); 2877 MonitorLocker ml(spawn_count_monitor_);
2878 ASSERT(*spawn_count_ > 0); 2878 ASSERT(*spawn_count_ > 0);
2879 *spawn_count_ = *spawn_count_ - 1; 2879 *spawn_count_ = *spawn_count_ - 1;
2880 ml.Notify(); 2880 ml.Notify();
2881 } 2881 }
2882 2882
2883 } // namespace dart 2883 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698