From b7dd18301a4dcc554d9f86d73c03738b446fc723 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Thu, 8 Jun 2023 17:10:47 -0700 Subject: [PATCH] Remove some dead code that threw file load exception (#87290) * Remove some dead code that threw file load exception * Remove FUSION_E_CACHEFILE_FAILED --- src/coreclr/dlls/mscorrc/mscorrc.rc | 1 - src/coreclr/inc/corerror.xml | 6 ----- src/coreclr/pal/prebuilt/corerror/mscorurt.rc | 1 - src/coreclr/pal/prebuilt/inc/corerror.h | 1 - src/coreclr/utilcode/ex.cpp | 1 - src/coreclr/vm/appdomain.cpp | 29 ++++++---------------- src/coreclr/vm/appdomain.hpp | 2 +- src/coreclr/vm/coreassemblyspec.cpp | 15 ----------- src/coreclr/vm/peimage.cpp | 14 ----------- src/coreclr/vm/peimage.h | 2 -- src/coreclr/vm/rexcep.h | 1 - src/libraries/Common/src/System/HResults.cs | 1 - .../src/System/Runtime/InteropServices/Marshal.cs | 1 - .../tests/System/IO/Exceptions.HResults.cs | 1 - .../System/IO/FileLoadException.InteropTests.cs | 1 - 15 files changed, 8 insertions(+), 69 deletions(-) diff --git a/src/coreclr/dlls/mscorrc/mscorrc.rc b/src/coreclr/dlls/mscorrc/mscorrc.rc index 4516dae..4e69980 100644 --- a/src/coreclr/dlls/mscorrc/mscorrc.rc +++ b/src/coreclr/dlls/mscorrc/mscorrc.rc @@ -115,7 +115,6 @@ BEGIN FUSION_E_REF_DEF_MISMATCH "The located assembly's manifest definition with name '%1' does not match the assembly reference." FUSION_E_PRIVATE_ASM_DISALLOWED "Assembly '%1' is required to be strongly named." FUSION_E_INVALID_NAME "The given assembly name, '%1', was invalid." - FUSION_E_CACHEFILE_FAILED "Failed to add file to AppDomain cache." FUSION_E_APP_DOMAIN_LOCKED "The requested assembly version conflicts with what is already bound in the app domain or specified in the manifest." IDS_EE_HASH_VAL_FAILED "Hash validation failed for file or assembly '%1'." CORSEC_E_INVALID_PUBLICKEY "The public key for assembly '%1' was invalid." diff --git a/src/coreclr/inc/corerror.xml b/src/coreclr/inc/corerror.xml index 81c7bab..7c0c385 100644 --- a/src/coreclr/inc/corerror.xml +++ b/src/coreclr/inc/corerror.xml @@ -184,12 +184,6 @@ The given assembly name was invalid. - - FUSION_E_CACHEFILE_FAILED - "Failed to add file to AppDomain cache." - Failed to add file to AppDomain cache - - FUSION_E_APP_DOMAIN_LOCKED "The requested assembly version conflicts with what is already bound in the app domain or specified in the manifest." diff --git a/src/coreclr/pal/prebuilt/corerror/mscorurt.rc b/src/coreclr/pal/prebuilt/corerror/mscorurt.rc index a30a45e..c0df09d 100644 --- a/src/coreclr/pal/prebuilt/corerror/mscorurt.rc +++ b/src/coreclr/pal/prebuilt/corerror/mscorurt.rc @@ -16,7 +16,6 @@ BEGIN MSG_FOR_URT_HR(FUSION_E_REF_DEF_MISMATCH) "The located assembly's manifest definition does not match the assembly reference." MSG_FOR_URT_HR(FUSION_E_PRIVATE_ASM_DISALLOWED) "A strongly-named assembly is required." MSG_FOR_URT_HR(FUSION_E_INVALID_NAME) "The given assembly name was invalid." - MSG_FOR_URT_HR(FUSION_E_CACHEFILE_FAILED) "Failed to add file to AppDomain cache." MSG_FOR_URT_HR(FUSION_E_APP_DOMAIN_LOCKED) "The requested assembly version conflicts with what is already bound in the app domain or specified in the manifest." MSG_FOR_URT_HR(COR_E_LOADING_REFERENCE_ASSEMBLY) "Reference assemblies cannot be loaded for execution." MSG_FOR_URT_HR(COR_E_AMBIGUOUSIMPLEMENTATION) "Ambiguous implementation found." diff --git a/src/coreclr/pal/prebuilt/inc/corerror.h b/src/coreclr/pal/prebuilt/inc/corerror.h index 8b64c94..e073dea 100644 --- a/src/coreclr/pal/prebuilt/inc/corerror.h +++ b/src/coreclr/pal/prebuilt/inc/corerror.h @@ -43,7 +43,6 @@ #define FUSION_E_REF_DEF_MISMATCH EMAKEHR(0x1040) #define FUSION_E_PRIVATE_ASM_DISALLOWED EMAKEHR(0x1044) #define FUSION_E_INVALID_NAME EMAKEHR(0x1047) -#define FUSION_E_CACHEFILE_FAILED EMAKEHR(0x1052) #define FUSION_E_APP_DOMAIN_LOCKED EMAKEHR(0x1053) #define COR_E_LOADING_REFERENCE_ASSEMBLY EMAKEHR(0x1058) #define COR_E_AMBIGUOUSIMPLEMENTATION EMAKEHR(0x106a) diff --git a/src/coreclr/utilcode/ex.cpp b/src/coreclr/utilcode/ex.cpp index f898fb1..8f6bdd0 100644 --- a/src/coreclr/utilcode/ex.cpp +++ b/src/coreclr/utilcode/ex.cpp @@ -573,7 +573,6 @@ LPCSTR Exception::GetHRSymbolicName(HRESULT hr) CASE_HRESULT(COR_E_APPDOMAINUNLOADED) CASE_HRESULT(COR_E_CANNOTUNLOADAPPDOMAIN) CASE_HRESULT(MSEE_E_ASSEMBLYLOADINPROGRESS) - CASE_HRESULT(FUSION_E_CACHEFILE_FAILED) CASE_HRESULT(FUSION_E_REF_DEF_MISMATCH) CASE_HRESULT(FUSION_E_PRIVATE_ASM_DISALLOWED) CASE_HRESULT(FUSION_E_INVALID_NAME) diff --git a/src/coreclr/vm/appdomain.cpp b/src/coreclr/vm/appdomain.cpp index d721089..c116276 100644 --- a/src/coreclr/vm/appdomain.cpp +++ b/src/coreclr/vm/appdomain.cpp @@ -3262,7 +3262,7 @@ PVOID AppDomain::GetFriendlyNameNoSet(bool* isUtf8) #ifndef DACCESS_COMPILE -BOOL AppDomain::AddFileToCache(AssemblySpec* pSpec, PEAssembly * pPEAssembly, BOOL fAllowFailure) +BOOL AppDomain::AddFileToCache(AssemblySpec* pSpec, PEAssembly * pPEAssembly) { CONTRACTL { @@ -3274,25 +3274,10 @@ BOOL AppDomain::AddFileToCache(AssemblySpec* pSpec, PEAssembly * pPEAssembly, BO } CONTRACTL_END; - { - GCX_PREEMP(); - DomainCacheCrstHolderForGCCoop holder(this); - - // !!! suppress exceptions - if(!m_AssemblyCache.StorePEAssembly(pSpec, pPEAssembly) && !fAllowFailure) - { - // TODO: Disabling the below assertion as currently we experience - // inconsistency on resolving the Microsoft.Office.Interop.MSProject.dll - // This causes below assertion to fire and crashes the VS. This issue - // is being tracked with Dev10 Bug 658555. Brought back it when this bug - // is fixed. - // _ASSERTE(FALSE); - - EEFileLoadException::Throw(pSpec, FUSION_E_CACHEFILE_FAILED, NULL); - } - } + GCX_PREEMP(); + DomainCacheCrstHolderForGCCoop holder(this); - return TRUE; + return m_AssemblyCache.StorePEAssembly(pSpec, pPEAssembly); } BOOL AppDomain::AddAssemblyToCache(AssemblySpec* pSpec, DomainAssembly *pAssembly) @@ -3505,10 +3490,10 @@ BOOL AppDomain::PostBindResolveAssembly(AssemblySpec *pPrePolicySpec, // The binder does a re-fetch of the // original binding spec and therefore will not cause inconsistency here. // For the purposes of the resolve event, failure to add to the cache still is a success. - AddFileToCache(pPrePolicySpec, result, TRUE /* fAllowFailure */); + AddFileToCache(pPrePolicySpec, result); if (*ppFailedSpec != pPrePolicySpec) { - AddFileToCache(pPostPolicySpec, result, TRUE /* fAllowFailure */ ); + AddFileToCache(pPostPolicySpec, result); } } } @@ -3569,7 +3554,7 @@ PEAssembly * AppDomain::BindAssemblySpec( // Failure to add simply means someone else beat us to it. In that case // the FindCachedFile call below (after catch block) will update result // to the cached value. - AddFileToCache(pSpec, result, TRUE /*fAllowFailure*/); + AddFileToCache(pSpec, result); } else { diff --git a/src/coreclr/vm/appdomain.hpp b/src/coreclr/vm/appdomain.hpp index ab928ca..5b5975c 100644 --- a/src/coreclr/vm/appdomain.hpp +++ b/src/coreclr/vm/appdomain.hpp @@ -1869,7 +1869,7 @@ public: BOOL IsCached(AssemblySpec *pSpec); #endif // DACCESS_COMPILE - BOOL AddFileToCache(AssemblySpec* pSpec, PEAssembly *pPEAssembly, BOOL fAllowFailure = FALSE); + BOOL AddFileToCache(AssemblySpec* pSpec, PEAssembly *pPEAssembly); BOOL RemoveFileFromCache(PEAssembly *pPEAssembly); BOOL AddAssemblyToCache(AssemblySpec* pSpec, DomainAssembly *pAssembly); diff --git a/src/coreclr/vm/coreassemblyspec.cpp b/src/coreclr/vm/coreassemblyspec.cpp index 5688d9a..2fc79fa 100644 --- a/src/coreclr/vm/coreassemblyspec.cpp +++ b/src/coreclr/vm/coreassemblyspec.cpp @@ -28,21 +28,6 @@ #include "../binder/inc/assemblybindercommon.hpp" #include "../binder/inc/applicationcontext.hpp" -static VOID ThrowLoadError(AssemblySpec * pSpec, HRESULT hr) -{ - CONTRACTL - { - THROWS; - MODE_ANY; - GC_TRIGGERS; - } - CONTRACTL_END; - - StackSString name; - pSpec->GetDisplayName(0, name); - EEFileLoadException::Throw(name, hr); -} - HRESULT AssemblySpec::Bind(AppDomain *pAppDomain, BINDER_SPACE::Assembly** ppAssembly) { CONTRACTL diff --git a/src/coreclr/vm/peimage.cpp b/src/coreclr/vm/peimage.cpp index 1610ef4..0f235ad 100644 --- a/src/coreclr/vm/peimage.cpp +++ b/src/coreclr/vm/peimage.cpp @@ -387,20 +387,6 @@ void PEImage::GetMVID(GUID *pMvid) #endif // _DEBUG } -void DECLSPEC_NORETURN PEImage::ThrowFormat(HRESULT hrError) -{ - CONTRACTL - { - GC_TRIGGERS; - THROWS; - MODE_ANY; - } - CONTRACTL_END; - - EEFileLoadException::Throw(m_path, hrError); -} - - //may outlive PEImage PEImage::IJWFixupData::IJWFixupData(void *pBase) : m_lock(CrstIJWFixupData), diff --git a/src/coreclr/vm/peimage.h b/src/coreclr/vm/peimage.h index 7fb9c4d..d30e561 100644 --- a/src/coreclr/vm/peimage.h +++ b/src/coreclr/vm/peimage.h @@ -232,8 +232,6 @@ private: static BOOL CompareImage(UPTR image1, UPTR image2); static BOOL CompareIJWDataBase(UPTR base, UPTR mapping); - void DECLSPEC_NORETURN ThrowFormat(HRESULT hr); - public: class IJWFixupData { diff --git a/src/coreclr/vm/rexcep.h b/src/coreclr/vm/rexcep.h index f3c08f4..bf424b7 100644 --- a/src/coreclr/vm/rexcep.h +++ b/src/coreclr/vm/rexcep.h @@ -143,7 +143,6 @@ DEFINE_EXCEPTION(g_SystemNS, FieldAccessException, false, C DEFINE_EXCEPTION(g_IONS, FileLoadException, true, COR_E_FILELOAD, - FUSION_E_CACHEFILE_FAILED, FUSION_E_INVALID_NAME, FUSION_E_PRIVATE_ASM_DISALLOWED, FUSION_E_REF_DEF_MISMATCH, diff --git a/src/libraries/Common/src/System/HResults.cs b/src/libraries/Common/src/System/HResults.cs index 37af241..2ce0acc 100644 --- a/src/libraries/Common/src/System/HResults.cs +++ b/src/libraries/Common/src/System/HResults.cs @@ -125,7 +125,6 @@ namespace System internal const int STG_E_PATHNOTFOUND = unchecked((int)0x80030003); internal const int CTL_E_PATHNOTFOUND = unchecked((int)0x800A004C); internal const int CTL_E_FILENOTFOUND = unchecked((int)0x800A0035); - internal const int FUSION_E_CACHEFILE_FAILED = unchecked((int)0x80131052); internal const int FUSION_E_INVALID_NAME = unchecked((int)0x80131047); internal const int FUSION_E_PRIVATE_ASM_DISALLOWED = unchecked((int)0x80131044); internal const int FUSION_E_REF_DEF_MISMATCH = unchecked((int)0x80131040); diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs index 692cdda..8e4f8fb 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs @@ -807,7 +807,6 @@ namespace System.Runtime.InteropServices HResult = errorCode }; } - case HResults.FUSION_E_CACHEFILE_FAILED: case HResults.FUSION_E_INVALID_NAME: case HResults.FUSION_E_PRIVATE_ASM_DISALLOWED: case HResults.FUSION_E_REF_DEF_MISMATCH: diff --git a/src/libraries/System.Runtime/tests/System/IO/Exceptions.HResults.cs b/src/libraries/System.Runtime/tests/System/IO/Exceptions.HResults.cs index 14e6ff8..777ffae 100644 --- a/src/libraries/System.Runtime/tests/System/IO/Exceptions.HResults.cs +++ b/src/libraries/System.Runtime/tests/System/IO/Exceptions.HResults.cs @@ -17,7 +17,6 @@ namespace System.IO.Tests public const int COR_E_EXCEPTION = unchecked((int)0x80131500); public const int COR_E_FILELOAD = unchecked((int)0x80131621); - public const int FUSION_E_CACHEFILE_FAILED = unchecked((int)0x80131052); public const int FUSION_E_INVALID_NAME = unchecked((int)0x80131047); public const int FUSION_E_PRIVATE_ASM_DISALLOWED = unchecked((int)0x80131044); public const int FUSION_E_REF_DEF_MISMATCH = unchecked((int)0x80131040); diff --git a/src/libraries/System.Runtime/tests/System/IO/FileLoadException.InteropTests.cs b/src/libraries/System.Runtime/tests/System/IO/FileLoadException.InteropTests.cs index 8018351..9d44977 100644 --- a/src/libraries/System.Runtime/tests/System/IO/FileLoadException.InteropTests.cs +++ b/src/libraries/System.Runtime/tests/System/IO/FileLoadException.InteropTests.cs @@ -12,7 +12,6 @@ namespace System.IO.Tests { [Theory] [InlineData(HResults.COR_E_FILELOAD)] - [InlineData(HResults.FUSION_E_CACHEFILE_FAILED)] [InlineData(HResults.FUSION_E_INVALID_NAME)] [InlineData(HResults.FUSION_E_PRIVATE_ASM_DISALLOWED)] [InlineData(HResults.FUSION_E_REF_DEF_MISMATCH)] -- 2.7.4