Skip to content

Commit

Permalink
Enable unloading of AssemblyLoadContext (dotnet#18476)
Browse files Browse the repository at this point in the history
Enable assembly unloading

* Allow PInvoke methods on collectible assemblies

* Fix test unloadability

Several hundreds of tests were using Helper class that created
GCHandle, but never freed it. That prevented unloading of those
tests. The change modifies the Helper class to keep the handle
in a finalizable object.

Several GCHandle related tests were not freeing the GCHandle they
allocated, so this change adds freeing them to enable the unloading.

* Add missing error messages to the resources

* Fix shuffle thunk cache for unloadability

* Add GetLoaderAllocator to ICLRPrivBinder
  • Loading branch information
janvorli committed Aug 23, 2018
1 parent 8013a4b commit 8cd4b39
Show file tree
Hide file tree
Showing 59 changed files with 1,242 additions and 419 deletions.
3 changes: 2 additions & 1 deletion clr.coreclr.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<FeatureCollectibleALC>true</FeatureCollectibleALC>
<FeatureEventTrace>true</FeatureEventTrace>
<FeatureHardwareIntrinsics>true</FeatureHardwareIntrinsics>
<FeatureICastable>true</FeatureICastable>
Expand Down Expand Up @@ -34,4 +35,4 @@
<FeatureWin32Registry>true</FeatureWin32Registry>
<FeatureProfAttach>true</FeatureProfAttach>
</PropertyGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion clr.defines.targets
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- Features we're currently flighting, but don't intend to ship in officially supported releases -->
<PropertyGroup Condition="'$(IsPrerelease)' == 'true'">
<FeatureDefaultInterfaces>true</FeatureDefaultInterfaces>
Expand All @@ -11,6 +10,7 @@
<DefineConstants Condition="'$(FeatureMulticastStubAsIL)' == 'true'">$(DefineConstants);FEATURE_MULTICASTSTUB_AS_IL</DefineConstants>
<DefineConstants Condition="'$(FeatureStubsAsIL)' == 'true'">$(DefineConstants);FEATURE_STUBS_AS_IL</DefineConstants>
<DefineConstants Condition="'$(FeatureClassicCominterop)' == 'true'">$(DefineConstants);FEATURE_CLASSIC_COMINTEROP</DefineConstants>
<DefineConstants Condition="'$(FeatureCollectibleALC)' == 'true'">$(DefineConstants);FEATURE_COLLECTIBLE_ALC</DefineConstants>
<DefineConstants Condition="'$(FeatureCominterop)' == 'true'">$(DefineConstants);FEATURE_COMINTEROP</DefineConstants>
<DefineConstants Condition="'$(FeatureCominteropApartmentSupport)' == 'true'">$(DefineConstants);FEATURE_COMINTEROP_APARTMENT_SUPPORT</DefineConstants>
<DefineConstants Condition="'$(FeatureCominteropUnmanagedActivation)' == 'true'">$(DefineConstants);FEATURE_COMINTEROP_UNMANAGED_ACTIVATION</DefineConstants>
Expand Down
12 changes: 12 additions & 0 deletions src/System.Private.CoreLib/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1912,6 +1912,18 @@
<data name="ArrayTypeMismatch_ConstrainedCopy" xml:space="preserve">
<value>Array.ConstrainedCopy will only work on array types that are provably compatible, without any form of boxing, unboxing, widening, or casting of each array element. Change the array types (i.e., copy a Derived[] to a Base[]), or use a mitigation strategy in the CER for Array.Copy's less powerful reliability contract, such as cloning the array or throwing away the potentially corrupt destination array.</value>
</data>
<data name="AssemblyLoadContext_Constructor_CannotInstantiateWhileUnloading" xml:space="preserve">
<value>Cannot instantiate AssemblyLoadContext while the current process is exiting.</value>
</data>
<data name="AssemblyLoadContext_Unload_CannotUnloadIfNotCollectible" xml:space="preserve">
<value>Cannot unload non-collectible AssemblyLoadContext.</value>
</data>
<data name="AssemblyLoadContext_Unload_AlreadyUnloaded" xml:space="preserve">
<value>Unload called on AssemblyLoadContext that is unloading or that was already unloaded.</value>
</data>
<data name="AssemblyLoadContext_Verify_NotUnloading" xml:space="preserve">
<value>AssemblyLoadContext is unloading or was already unloaded.</value>
</data>
<data name="AssertionFailed" xml:space="preserve">
<value>Assertion failed.</value>
</data>
Expand Down
Loading

0 comments on commit 8cd4b39

Please sign in to comment.