-
由 Tomáš Rylek 提交于
I originally hit this bug when testing my Crossgen2 perf optimization change involving only registering composite code range once but I managed to disprove the bug was caused by this change. Indeed, it was caused by my earlier change improving component assembly caching. In my overzealous attempt to make sure the assembly gets always registered I added a new method NativeImage::AddComponentAssemblyToCache that registered the assembly which had triggered the native image load in the first place. This was incorrect, by that point the assembly wasn't yet fully initialized and putting it in the cache made it visible to other threads that subsequently crashed trying to access the assembly before it was fully loaded. Furthermore it was unnecessary, once the assembly gets loaded, it gets stored in the cache via the call to SetNativeMetadataAssemblyRefInCache from ZapSig::DecodeModuleFromIndex. Before the fix I was able to repro the bug locally typically after about 500 iterations of the thread14 unit test, with the fix I was unable to repro after 4500 iterations. Thanks Tomas Fixes: https://github.com/dotnet/runtime/issues/66954 Probably also fixes: https://github.com/dotnet/runtime/issues/66210
a2448b02