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

Unified Diff: runtime/vm/snapshot.cc

Issue 926073002: Fix crash that happens when we send an object whose type is in a defer (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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/snapshot.cc
===================================================================
--- runtime/vm/snapshot.cc (revision 43771)
+++ runtime/vm/snapshot.cc (working copy)
@@ -7,6 +7,7 @@
#include "platform/assert.h"
#include "vm/bootstrap.h"
#include "vm/class_finalizer.h"
+#include "vm/dart_entry.h"
#include "vm/exceptions.h"
#include "vm/heap.h"
#include "vm/lockers.h"
@@ -223,11 +224,15 @@
// Read the library/class information and lookup the class.
str_ ^= ReadObjectImpl(class_header);
library_ = Library::LookupLibrary(str_);
- ASSERT(!library_.IsNull());
+ if (library_.IsNull() || !library_.Loaded()) {
+ SetReadException("Invalid object found in message.");
+ }
str_ ^= ReadObjectImpl();
cls = library_.LookupClass(str_);
+ if (cls.IsNull()) {
+ SetReadException("Invalid object found in message.");
+ }
cls.EnsureIsFinalized(isolate());
- ASSERT(!cls.IsNull());
return cls.raw();
}
@@ -247,6 +252,24 @@
}
+void SnapshotReader::SetReadException(const char* msg) {
+ Isolate* isolate = Isolate::Current();
+ const String& error_str = String::Handle(isolate, String::New(msg));
+ const Array& args = Array::Handle(isolate, Array::New(1));
+ args.SetAt(0, error_str);
+ Object& result = Object::Handle(isolate);
+ const Library& library = Library::Handle(isolate, Library::CoreLibrary());
+ result = DartLibraryCalls::InstanceCreate(library,
+ Symbols::ArgumentError(),
+ Symbols::Dot(),
+ args);
+ const Stacktrace& stacktrace = Stacktrace::Handle(isolate);
+ const UnhandledException& error = UnhandledException::Handle(
+ isolate, UnhandledException::New(Instance::Cast(result), stacktrace));
+ isolate->long_jump_base()->Jump(1, error);
+}
+
+
RawObject* SnapshotReader::ReadObjectImpl(intptr_t header_value) {
if (IsVMIsolateObject(header_value)) {
return ReadVMIsolateObject(header_value);

Powered by Google App Engine
This is Rietveld 408576698