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

Unified Diff: runtime/vm/raw_object.cc

Issue 10693044: Enhance raw object validation check and enable checks in release builds. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/raw_object.cc
diff --git a/runtime/vm/raw_object.cc b/runtime/vm/raw_object.cc
index 4eecb31cda4c90d553474470f7357f83fa6cb8e6..30b52f483b86c489314b002bd3ec60ee8adc81ff 100644
--- a/runtime/vm/raw_object.cc
+++ b/runtime/vm/raw_object.cc
@@ -14,8 +14,6 @@
namespace dart {
void RawObject::Validate(Isolate* isolate) const {
- // Validation only happens in DEBUG builds.
-#if defined(DEBUG)
if (Object::null_class_ == reinterpret_cast<RawClass*>(kHeapObjectTag)) {
// Validation relies on properly initialized class classes. Skip if the
// VM is still being initialized.
@@ -27,8 +25,22 @@ void RawObject::Validate(Isolate* isolate) const {
}
// Validate that the tags_ field is sensible.
uword tags = ptr()->tags_;
- ASSERT((tags & 0x000000f0) == 0);
-#endif
+ uword reserved = 0;
+ reserved |= (1 << kReservedBit10K);
+ reserved |= (1 << kReservedBit100K);
+ reserved |= (1 << kReservedBit1M);
+ reserved |= (1 << kReservedBit10M);
+ if ((tags & reserved) != 0) {
+ FATAL1("Invalid tags field encountered %#lx\n", tags);
+ }
+ intptr_t class_id = ClassIdTag::decode(tags);
+ if (!isolate->class_table()->IsValidIndex(class_id)) {
+ FATAL1("Invalid class id encountered %d\n", class_id);
+ }
+ intptr_t size = SizeTag::decode(tags);
+ if (size != 0 && size != SizeFromClass()) {
+ FATAL1("Inconsistent class size encountered %d\n", size);
+ }
}
« 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