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

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

Issue 2164703003: Fix for use-after-free of reload context (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: s/test_mode/dont_delete_reload_context/, simplifications 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 | « runtime/vm/isolate.h ('k') | runtime/vm/isolate_reload.h » ('j') | 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 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 #else 1078 #else
1079 return false; 1079 return false;
1080 #endif 1080 #endif
1081 } 1081 }
1082 1082
1083 1083
1084 #ifndef PRODUCT 1084 #ifndef PRODUCT
1085 void Isolate::ReportReloadError(const Error& error) { 1085 void Isolate::ReportReloadError(const Error& error) {
1086 ASSERT(IsReloading()); 1086 ASSERT(IsReloading());
1087 reload_context_->AbortReload(error); 1087 reload_context_->AbortReload(error);
1088 }
1089
1090
1091 void Isolate::ReloadSources(bool dont_delete_reload_context) {
1092 ASSERT(!IsReloading());
1093 has_attempted_reload_ = true;
1094 reload_context_ = new IsolateReloadContext(this);
1095 reload_context_->StartReload();
1096 if (dont_delete_reload_context) {
1097 // Unit tests use the reload context later. Caller is responsible
1098 // for deleting the context.
1099 return;
1100 }
1101 DeleteReloadContext();
1102 }
1103
1104
1105 void Isolate::DeleteReloadContext() {
1088 delete reload_context_; 1106 delete reload_context_;
1089 reload_context_ = NULL; 1107 reload_context_ = NULL;
1090 } 1108 }
1091
1092
1093 void Isolate::ReloadSources(bool test_mode) {
1094 ASSERT(!IsReloading());
1095 has_attempted_reload_ = true;
1096 reload_context_ = new IsolateReloadContext(this, test_mode);
1097 reload_context_->StartReload();
1098 }
1099 #endif // !PRODUCT 1109 #endif // !PRODUCT
1100 1110
1101 1111
1102 void Isolate::DoneFinalizing() { 1112 void Isolate::DoneFinalizing() {
1103 NOT_IN_PRODUCT( 1113 NOT_IN_PRODUCT(
1104 if (IsReloading()) { 1114 if (IsReloading()) {
1105 reload_context_->FinishReload(); 1115 reload_context_->FinishReload();
1106 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
1108 // context on the isolate so that it can be used by unit tests.
1109 return;
1110 }
1111 if (reload_context_->has_error()) { 1116 if (reload_context_->has_error()) {
1112 // Remember the reload error. 1117 // Remember the reload error.
1113 sticky_reload_error_ = reload_context_->error(); 1118 sticky_reload_error_ = reload_context_->error();
1114 } 1119 } else {
1115 if (!reload_context_->has_error()) {
1116 reload_context_->ReportSuccess(); 1120 reload_context_->ReportSuccess();
1117 } 1121 }
1118 delete reload_context_;
1119 reload_context_ = NULL;
1120 } 1122 }
1121 ) 1123 )
1122 } 1124 }
1123 1125
1124 1126
1125 1127
1126 bool Isolate::MakeRunnable() { 1128 bool Isolate::MakeRunnable() {
1127 ASSERT(Isolate::Current() == NULL); 1129 ASSERT(Isolate::Current() == NULL);
1128 1130
1129 MutexLocker ml(mutex_); 1131 MutexLocker ml(mutex_);
(...skipping 1744 matching lines...) Expand 10 before | Expand all | Expand 10 after
2874 void IsolateSpawnState::DecrementSpawnCount() { 2876 void IsolateSpawnState::DecrementSpawnCount() {
2875 ASSERT(spawn_count_monitor_ != NULL); 2877 ASSERT(spawn_count_monitor_ != NULL);
2876 ASSERT(spawn_count_ != NULL); 2878 ASSERT(spawn_count_ != NULL);
2877 MonitorLocker ml(spawn_count_monitor_); 2879 MonitorLocker ml(spawn_count_monitor_);
2878 ASSERT(*spawn_count_ > 0); 2880 ASSERT(*spawn_count_ > 0);
2879 *spawn_count_ = *spawn_count_ - 1; 2881 *spawn_count_ = *spawn_count_ - 1;
2880 ml.Notify(); 2882 ml.Notify();
2881 } 2883 }
2882 2884
2883 } // namespace dart 2885 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/isolate_reload.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698