diff options
author | Fadi Hanna <fadim@microsoft.com> | 2016-03-30 09:27:04 -0700 |
---|---|---|
committer | Fadi Hanna <fadim@microsoft.com> | 2016-03-30 09:27:04 -0700 |
commit | a62cb372fb7edf1cf7d7b783bfa653f58dc68a7a (patch) | |
tree | 12ed7553b05ad5ead85c984f68d9128d255e931e | |
parent | 72f6c4e1d552474f80b1814288eeb79e09e5760f (diff) | |
download | coreclr-a62cb372fb7edf1cf7d7b783bfa653f58dc68a7a.tar.gz coreclr-a62cb372fb7edf1cf7d7b783bfa653f58dc68a7a.tar.bz2 coreclr-a62cb372fb7edf1cf7d7b783bfa653f58dc68a7a.zip |
Fixing contracts violations, and adding missing contracts to some APIs.
Changing native format reader failure mode to fail fast instead of throwing and exception.
[tfs-changeset: 1591477]
-rw-r--r-- | src/vm/clsload.hpp | 8 | ||||
-rw-r--r-- | src/vm/nativeformatreader.h | 6 | ||||
-rw-r--r-- | src/vm/readytoruninfo.cpp | 2 |
3 files changed, 14 insertions, 2 deletions
diff --git a/src/vm/clsload.hpp b/src/vm/clsload.hpp index ca561a8049..e2705ae2e4 100644 --- a/src/vm/clsload.hpp +++ b/src/vm/clsload.hpp @@ -87,18 +87,24 @@ public: const HashedTypeEntry& SetClassHashBasedEntryValue(EEClassHashEntry_t * pClassHashEntry) { + LIMITED_METHOD_CONTRACT; + m_EntryType = EntryType::IsHashedClassEntry; m_pClassHashEntry = dac_cast<PTR_EEClassHashEntry>(pClassHashEntry); return *this; } EEClassHashEntry_t * GetClassHashBasedEntryValue() { + LIMITED_METHOD_CONTRACT; + _ASSERT(m_EntryType == EntryType::IsHashedClassEntry); return m_pClassHashEntry; } const HashedTypeEntry& SetTokenBasedEntryValue(mdTypeDef typeToken, Module * pModule) { + LIMITED_METHOD_CONTRACT; + m_EntryType = EntryType::IsHashedTokenEntry; m_TokenAndModulePair.m_TypeToken = typeToken; m_TokenAndModulePair.m_pModule = pModule; @@ -106,6 +112,8 @@ public: } const TokenTypeEntry& GetTokenBasedEntryValue() { + LIMITED_METHOD_CONTRACT; + _ASSERT(m_EntryType == EntryType::IsHashedTokenEntry); return m_TokenAndModulePair; } diff --git a/src/vm/nativeformatreader.h b/src/vm/nativeformatreader.h index cfebb498ca..a410884626 100644 --- a/src/vm/nativeformatreader.h +++ b/src/vm/nativeformatreader.h @@ -44,7 +44,11 @@ namespace NativeFormat void ThrowBadImageFormatException() { _ASSERTE(false); - ThrowHR(COR_E_BADIMAGEFORMAT); + +#ifndef DACCESS_COMPILE + // Failfast instead of throwing, to avoid violating NOTHROW contracts of callers + EEPOLICY_HANDLE_FATAL_ERROR(COR_E_BADIMAGEFORMAT); +#endif } uint EnsureOffsetInRange(uint offset, uint lookAhead) diff --git a/src/vm/readytoruninfo.cpp b/src/vm/readytoruninfo.cpp index d00db7150f..1faf820a1c 100644 --- a/src/vm/readytoruninfo.cpp +++ b/src/vm/readytoruninfo.cpp @@ -84,7 +84,7 @@ BOOL ReadyToRunInfo::TryLookupTypeTokenFromName(NameHandle *pName, mdToken * pFo { GC_NOTRIGGER; NOTHROW; - SO_TOLERANT; + SO_INTOLERANT; SUPPORTS_DAC; PRECONDITION(!m_availableTypesHashtable.IsNull()); } |