Disable noncollectible alc finalization (dotnet/coreclr#21189)
authorJan Vorlicek <janvorli@microsoft.com>
Tue, 27 Nov 2018 03:15:45 +0000 (04:15 +0100)
committerJan Kotas <jkotas@microsoft.com>
Tue, 27 Nov 2018 03:15:45 +0000 (19:15 -0800)
commitb7404da4def231d66006a8a94a100244d818f2e4
treee1bb2bf3d573d0c46a9d7b3b3afd14df59601cee
parentf117f041d8dbde0abad6fa7fcb224c7a19e77066
Disable noncollectible alc finalization (dotnet/coreclr#21189)

* Disable noncollectible AssemblyLoadContext finalization

The constructor of AssemblyLoadContext was missing a call to
GC.SuppressFinalize for non-collectible AssemblyLoadContext. That means
that the finalizer can be executed and unloading being initialized even
for non-collectible AssemblyLoadContext.
This change fixes that.

* SuppressFinalize non-collectible AssemblyLoadContext

The finalizer for the non-collectible AssemblyLoadContext is never
called and so it should not be in the finalization queue.

* Handle finalizer call without constructor executed

Check if the constructor was executed before we run the finalizer code.

Commit migrated from https://github.com/dotnet/coreclr/commit/ac732ffb6d2ff4d2bec72ac5ca0785ace4ace20a
src/coreclr/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs