Turn segfauts into asserts in debug build (#9509)
authorSteve MacLean <sdmaclea@qti.qualcomm.com>
Sat, 11 Feb 2017 03:53:27 +0000 (22:53 -0500)
committerJan Kotas <jkotas@microsoft.com>
Sat, 11 Feb 2017 03:53:27 +0000 (19:53 -0800)
* Prevent segfault if method table is null

* ValidateInner() check method table is not null

src/inc/stdmacros.h
src/vm/object.cpp

index ab77a2c..3ec8bec 100644 (file)
@@ -277,7 +277,7 @@ inline ULONG RoundUpToPower2(ULONG x)
 
 
 #define DBG_GET_CLASS_NAME(pMT)        \
-        (pMT)->GetClass()->GetDebugClassName()
+        (((pMT) == NULL)  ? NULL : (pMT)->GetClass()->GetDebugClassName())
 
 #define DBG_CLASS_NAME_MT(pMT)         \
         (DBG_GET_CLASS_NAME(pMT) == NULL) ? "<null-class>" : DBG_GET_CLASS_NAME(pMT) 
index b219eb9..21e56ab 100644 (file)
@@ -1737,9 +1737,10 @@ VOID Object::ValidateInner(BOOL bDeep, BOOL bVerifyNextHeader, BOOL bVerifySyncB
         AVInRuntimeImplOkayHolder avOk;
 
         MethodTable *pMT = GetGCSafeMethodTable();
+
         lastTest = 1;
 
-        CHECK_AND_TEAR_DOWN(pMT->Validate());
+        CHECK_AND_TEAR_DOWN(pMT && pMT->Validate());
         lastTest = 2;
 
         bool noRangeChecks =