Fix dynamic class zeroing (#80822)
authorJan Vorlicek <janvorli@microsoft.com>
Thu, 19 Jan 2023 13:46:55 +0000 (14:46 +0100)
committerGitHub <noreply@github.com>
Thu, 19 Jan 2023 13:46:55 +0000 (14:46 +0100)
Recent change in the `ThreadLocalModule::AllocateDynamicClass` has
accidentally removed zeroing for new  CollectibleDynamicEntry instances.
That leads to crashes when running code in an unloadable context.

This change fixes that.

src/coreclr/vm/threadstatics.h

index a7001edd2d2646daff2433724a88dbbf3a3de413..f002f0059ce6f24384c0007eecdd5dcf41735e44 100644 (file)
@@ -96,9 +96,9 @@ struct ThreadLocalModule
             LIMITED_METHOD_CONTRACT;
         }
 
-        LOADERHANDLE        m_hGCStatics;
-        LOADERHANDLE        m_hNonGCStatics;
-        PTR_LoaderAllocator m_pLoaderAllocator;
+        LOADERHANDLE        m_hGCStatics = NULL;
+        LOADERHANDLE        m_hNonGCStatics = NULL;
+        PTR_LoaderAllocator m_pLoaderAllocator = NULL;
     };
     typedef DPTR(CollectibleDynamicEntry) PTR_CollectibleDynamicEntry;