Closed
Description
Description
This started happening here: dotnet/android#6363 (comment)
We think this diff: 491ed9a...e013f14
A test of the form:
var d = false;
var f = false;
FinalizerHelpers.PerformNoPinAction (() => {
var v = new JavaDisposedObject (() => d = true, () => f = true);
GC.KeepAlive (v);
});
JniEnvironment.Runtime.ValueManager.CollectPeers ();
GC.WaitForPendingFinalizers ();
JniEnvironment.Runtime.ValueManager.CollectPeers ();
GC.WaitForPendingFinalizers ();
Assert (!d, "d should be false");
Assert (f, "f should be true");
Reproduction Steps
I created a self-contained repro: https://github.com/jonathanpeppers/net6-finalizer-repro
The interesting bit, is I don't even have to set UseInterpreter=true
. The repro fails with JIT and interpreter.
Expected behavior
The above unit test passes.
Actual behavior
The above unit test fails.
Regression?
Yes, this has been working in Xamarin.Android for some time.
It worked previously in the 6.0.0-rtm.21472.13 version of the Mono/Android runtime packs.
Known Workarounds
Use older runtime packs?
<Target Name="UpdateMonoRuntimePacks" BeforeTargets="ProcessFrameworkReferences">
<ItemGroup>
<KnownRuntimePack
Update="Microsoft.NETCore.App"
Condition=" '%(KnownRuntimePack.TargetFramework)' == 'net6.0' "
LatestRuntimeFrameworkVersion="6.0.0-rtm.21472.13"
/>
</ItemGroup>
</Target>
Configuration
.NET 6.0.100-rtm.21518.6
Other information
No response