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

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

Issue 933183003: Fix use-after-free in MessageHandler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
« 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/message_handler.h" 5 #include "vm/message_handler.h"
6 6
7 #include "vm/dart.h" 7 #include "vm/dart.h"
8 #include "vm/lockers.h" 8 #include "vm/lockers.h"
9 #include "vm/port.h" 9 #include "vm/port.h"
10 10
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 OS::Print("[<] Handling message:\n" 150 OS::Print("[<] Handling message:\n"
151 "\thandler: %s\n" 151 "\thandler: %s\n"
152 "\tport: %" Pd64 "\n", 152 "\tport: %" Pd64 "\n",
153 name(), message->dest_port()); 153 name(), message->dest_port());
154 } 154 }
155 155
156 // Release the monitor_ temporarily while we handle the message. 156 // Release the monitor_ temporarily while we handle the message.
157 // The monitor was acquired in MessageHandler::TaskCallback(). 157 // The monitor was acquired in MessageHandler::TaskCallback().
158 monitor_.Exit(); 158 monitor_.Exit();
159 Message::Priority saved_priority = message->priority(); 159 Message::Priority saved_priority = message->priority();
160 Dart_Port saved_dest_port = message->dest_port();
160 result = HandleMessage(message); 161 result = HandleMessage(message);
162 message = NULL; // May be deleted by now.
161 monitor_.Enter(); 163 monitor_.Enter();
162 if (FLAG_trace_isolates) { 164 if (FLAG_trace_isolates) {
163 OS::Print("[.] Message handled:\n" 165 OS::Print("[.] Message handled:\n"
164 "\thandler: %s\n" 166 "\thandler: %s\n"
165 "\tport: %" Pd64 "\n", 167 "\tport: %" Pd64 "\n",
166 name(), message->dest_port()); 168 name(), saved_dest_port);
167 } 169 }
168 if (!result) { 170 if (!result) {
169 // If we hit an error, we're done processing messages. 171 // If we hit an error, we're done processing messages.
170 break; 172 break;
171 } 173 }
172 // Some callers want to process only one normal message and then quit. At 174 // Some callers want to process only one normal message and then quit. At
173 // the same time it is OK to process multiple OOB messages. 175 // the same time it is OK to process multiple OOB messages.
174 if ((saved_priority == Message::kNormalPriority) && 176 if ((saved_priority == Message::kNormalPriority) &&
175 !allow_multiple_normal_messages) { 177 !allow_multiple_normal_messages) {
176 break; 178 break;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 311
310 void MessageHandler::decrement_live_ports() { 312 void MessageHandler::decrement_live_ports() {
311 MonitorLocker ml(&monitor_); 313 MonitorLocker ml(&monitor_);
312 #if defined(DEBUG) 314 #if defined(DEBUG)
313 CheckAccess(); 315 CheckAccess();
314 #endif 316 #endif
315 live_ports_--; 317 live_ports_--;
316 } 318 }
317 319
318 } // namespace dart 320 } // 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