{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/coreclr/issues/18536","repository_url":"https://api.github.com/repos/dotnet/coreclr","labels_url":"https://api.github.com/repos/dotnet/coreclr/issues/18536/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/coreclr/issues/18536/comments","events_url":"https://api.github.com/repos/dotnet/coreclr/issues/18536/events","html_url":"https://github.com/dotnet/coreclr/issues/18536","id":333528154,"node_id":"MDU6SXNzdWUzMzM1MjgxNTQ=","number":18536,"title":"Adding types to R2R images using profiler metadata emit at ModuleLoadFinished triggers AV","user":{"login":"noahfalk","id":6243776,"node_id":"MDQ6VXNlcjYyNDM3NzY=","avatar_url":"https://avatars0.githubusercontent.com/u/6243776?v=4","gravatar_id":"","url":"https://api.github.com/users/noahfalk","html_url":"https://github.com/noahfalk","followers_url":"https://api.github.com/users/noahfalk/followers","following_url":"https://api.github.com/users/noahfalk/following{/other_user}","gists_url":"https://api.github.com/users/noahfalk/gists{/gist_id}","starred_url":"https://api.github.com/users/noahfalk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noahfalk/subscriptions","organizations_url":"https://api.github.com/users/noahfalk/orgs","repos_url":"https://api.github.com/users/noahfalk/repos","events_url":"https://api.github.com/users/noahfalk/events{/privacy}","received_events_url":"https://api.github.com/users/noahfalk/received_events","type":"User","site_admin":false},"labels":[{"id":196940783,"node_id":"MDU6TGFiZWwxOTY5NDA3ODM=","url":"https://api.github.com/repos/dotnet/coreclr/labels/area-Diagnostics","name":"area-Diagnostics","color":"d4c5f9","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/dotnet/coreclr/milestones/18","html_url":"https://github.com/dotnet/coreclr/milestone/18","labels_url":"https://api.github.com/repos/dotnet/coreclr/milestones/18/labels","id":3246413,"node_id":"MDk6TWlsZXN0b25lMzI0NjQxMw==","number":18,"title":"3.0","description":".NET Core 3.0, next major release after 2.1. See [official release dates](https://github.com/dotnet/core/blob/master/roadmap.md) for details.\r\n\r\nWe will move important issues from Future to 3.0 as the priorities and dates for next release become more clear.","creator":{"login":"karelz","id":5776068,"node_id":"MDQ6VXNlcjU3NzYwNjg=","avatar_url":"https://avatars2.githubusercontent.com/u/5776068?v=4","gravatar_id":"","url":"https://api.github.com/users/karelz","html_url":"https://github.com/karelz","followers_url":"https://api.github.com/users/karelz/followers","following_url":"https://api.github.com/users/karelz/following{/other_user}","gists_url":"https://api.github.com/users/karelz/gists{/gist_id}","starred_url":"https://api.github.com/users/karelz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karelz/subscriptions","organizations_url":"https://api.github.com/users/karelz/orgs","repos_url":"https://api.github.com/users/karelz/repos","events_url":"https://api.github.com/users/karelz/events{/privacy}","received_events_url":"https://api.github.com/users/karelz/received_events","type":"User","site_admin":false},"open_issues":120,"closed_issues":89,"state":"open","created_at":"2018-04-05T22:09:22Z","updated_at":"2018-06-26T23:27:56Z","due_on":null,"closed_at":null},"comments":0,"created_at":"2018-06-19T05:53:51Z","updated_at":"2018-06-27T05:03:34Z","closed_at":null,"author_association":"MEMBER","body":"After the ModuleLoadFinished callback returns the runtime attempts to update a type loader cache called the 'AvailableClassHash'. Historically this cache was always created eagerly prior to ModuleLoadFinished being called but ReadyToRun changed the behavior to be lazy. Unfortunately the code path the profiler used to update that cache wasn't changed to account for the lazy creation so it attempts to insert into the non-existent cache and triggers an AV. I stumbled upon the issue accidentally while trying to test something else. My repro was adding a type forwarder to System.Runtime.dll but based on code review I think the issue also applies to adding new TypeDefs.\r\nCurrently 'Ready To Run' compilation is used for all framework images except System.Private.CoreLib.dll.\r\n\r\nCallstack with the AV:\r\n\r\n \tcoreclr.dll!ClassLoader::AddExportedTypeHaveLock(Module * pManifestModule, unsigned int cl, AllocMemTracker * pamTracker) Line 4771\tC++\r\n \t[Inline Frame] coreclr.dll!ClassLoader::AddExportedTypeDontHaveLock(Module *) Line 4679\tC++\r\n\tcoreclr.dll!Assembly::AddExportedType(unsigned int cl) Line 2176\tC++\r\n \tcoreclr.dll!Module::NotifyProfilerLoadFinished(HRESULT hr) Line 248\tC++\r\n \tcoreclr.dll!DomainFile::PostLoadLibrary() Line 1035\tC++\r\n \tcoreclr.dll!DomainFile::DoIncrementalLoad(FileLoadLevel level) Line 582\tC++\r\n \tcoreclr.dll!AppDomain::TryIncrementalLoad(DomainFile * pFile, FileLoadLevel workLevel, Wrapper<FileLoadLock *,&DoNothing<FileLoadLock *>,&FileLoadLock::HolderLeave,0,&CompareDefault<FileLoadLock *>,2,1> & lockHolder) Line 5841\tC++\r\n \tcoreclr.dll!AppDomain::LoadDomainFile(FileLoadLock * pLock, FileLoadLevel targetLevel) Line 5773\tC++\r\n \tcoreclr.dll!AppDomain::LoadDomainAssemblyInternal(AssemblySpec * pIdentity, PEAssembly * pFile, FileLoadLevel targetLevel) Line 5603\tC++\r\n \tcoreclr.dll!AppDomain::LoadDomainAssembly(AssemblySpec * pSpec, PEAssembly * pFile, FileLoadLevel targetLevel) Line 5490\tC++\r\n \tcoreclr.dll!Module::LoadAssembly(AppDomain * pDomain, unsigned int kAssemblyRef, const char * szWinRtTypeNamespace, const char * szWinRtTypeClassName) Line 5613\tC++\r\n \tcoreclr.dll!Assembly::FindModuleByTypeRef(Module * pModule, unsigned int tkType, Loader::LoadFlag loadFlag, int * pfNoResolutionScope) Line 1274\tC++\r\n \tcoreclr.dll!ClassLoader::LoadTypeDefOrRefThrowing(Module * pModule, unsigned int typeDefOrRef, ClassLoader::NotFoundAction fNotFoundAction, ClassLoader::PermitUninstantiatedFlag fUninstantiated, unsigned int tokenNotToLoad, ClassLoadLevel level) Line 3003\tC++\r\n \tcoreclr.dll!ClassLoader::LoadApproxTypeThrowing(Module * pModule, unsigned int tok, SigPointer * pSigInst, const SigTypeContext * pClassTypeContext) Line 3416\tC++\r\n \t[Inline Frame] coreclr.dll!ClassLoader::LoadApproxParentThrowing(Module *) Line 3462\tC++\r\n \tcoreclr.dll!ClassLoader::CreateTypeHandleForTypeDefThrowing(Module * pModule, unsigned int cl, Instantiation inst, AllocMemTracker * pamTracker) Line 11906\tC++\r\n \tcoreclr.dll!ClassLoader::CreateTypeHandleForTypeKey(TypeKey * pKey, AllocMemTracker * pamTracker) Line 3589\tC++\r\n \tcoreclr.dll!ClassLoader::LoadTypeHandleForTypeKey_Body(TypeKey * pTypeKey, TypeHandle typeHnd, ClassLoadLevel targetLevel) Line 4325\tC++\r\n \tcoreclr.dll!ClassLoader::LoadTypeHandleForTypeKey(TypeKey * pTypeKey, TypeHandle typeHnd, ClassLoadLevel targetLevel, const InstantiationContext * pInstContext) Line 4044\tC++\r\n \tcoreclr.dll!ClassLoader::LoadTypeDefThrowing(Module * pModule, unsigned int typeDef, ClassLoader::NotFoundAction fNotFoundAction, ClassLoader::PermitUninstantiatedFlag fUninstantiated, unsigned int tokenNotToLoad, ClassLoadLevel level, Instantiation * pTargetInstantiation) Line 2887\tC++\r\n \tcoreclr.dll!ClassLoader::LoadTypeDefOrRefThrowing(Module * pModule, unsigned int typeDefOrRef, ClassLoader::NotFoundAction fNotFoundAction, ClassLoader::PermitUninstantiatedFlag fUninstantiated, unsigned int tokenNotToLoad, ClassLoadLevel level) Line 3065\tC++\r\n \tcoreclr.dll!Assembly::GetEntryPoint() Line 1918\tC++\r\n \tcoreclr.dll!Assembly::ExecuteMainMethod(PtrArray * * stringArgs, int) Line 1792\tC++\r\n \tcoreclr.dll!CorHost2::ExecuteAssembly(unsigned long dwAppDomainId, const wchar_t * pwzAssemblyPath, int argc, const wchar_t * * argv, unsigned long * pReturnValue) Line 491\tC++\r\n \tcoreclr.dll!coreclr_execute_assembly(void * hostHandle, unsigned int domainId, int argc, const char * * argv, const char * managedAssemblyPath, unsigned int * exitCode) Line 407\tC++\r\n"},"comment":{"url":"https://api.github.com/repos/dotnet/coreclr/issues/comments/400543550","html_url":"https://github.com/dotnet/coreclr/issues/18536#issuecomment-400543550","issue_url":"https://api.github.com/repos/dotnet/coreclr/issues/18536","id":400543550,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMDU0MzU1MA==","user":{"login":"noahfalk","id":6243776,"node_id":"MDQ6VXNlcjYyNDM3NzY=","avatar_url":"https://avatars0.githubusercontent.com/u/6243776?v=4","gravatar_id":"","url":"https://api.github.com/users/noahfalk","html_url":"https://github.com/noahfalk","followers_url":"https://api.github.com/users/noahfalk/followers","following_url":"https://api.github.com/users/noahfalk/following{/other_user}","gists_url":"https://api.github.com/users/noahfalk/gists{/gist_id}","starred_url":"https://api.github.com/users/noahfalk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noahfalk/subscriptions","organizations_url":"https://api.github.com/users/noahfalk/orgs","repos_url":"https://api.github.com/users/noahfalk/repos","events_url":"https://api.github.com/users/noahfalk/events{/privacy}","received_events_url":"https://api.github.com/users/noahfalk/received_events","type":"User","site_admin":false},"created_at":"2018-06-27T05:03:34Z","updated_at":"2018-06-27T05:03:34Z","author_association":"MEMBER","body":"In order to unblock myself locally I created a partial fix which can be found at: https://github.com/noahfalk/coreclr/tree/fix_r2r_export_master \r\nI'm not actively continuing work here however, anyone can pick up where I left off."}}
{"actor":{"display_login":"noahfalk"}}