Closed jonathanpeppers closed 12 hours ago
Actually, there might be a test failure:
Mono.Android.NET_Tests, Java.InteropTests.InvokeVirtualFromConstructorTests.ActivationConstructor
Java.Lang.UnsatisfiedLinkError : No implementation found for void net.dot.jni.test.CallVirtualFromConstructorDerived.calledFromConstructor(int) (tried Java_net_dot_jni_test_CallVirtualFromConstructorDerived_calledFromConstructor and Java_net_dot_jni_test_CallVirtualFromConstructorDerived_calledFromConstructor__I)
I still see the UnsatisfiedLinkError
, which I'm confused how my changes cause it. It even happens in the Debug
build.
Context: https://discord.com/channels/732297728826277939/732297916680765551/1308554103206580244 Fixes: https://github.com/dotnet/android/issues/9133 Context: 86260ed3
Various customers have been reporting
UnauthorizedAccessExceptions
in incremental builds, which seems to be a new problem in .NET 9. We were not able to reproduce the issue locally, but with the number of reports it seems to be a real issue.One customer shared a
MSBuild.dmp
file (while the file was locked), where I could observe the objects in memory:Then realized the problem was:
We opened some
.dll
files withMono.Cecil
.They were never closed.
Future incremental build attempts would fail on various operations of the same
.dll
files.We were also storing some static state (
NativeCodeGenState
) to be shared across multiple MSBuild tasks:NativeCodeGenState
also holds aXAAssemblyResolver
in aResolver
property. This means thisXAAssemblyResolver
instance would also be kept alive.It appears we only use the static
Template
property for abool
flag, so I changed the property to abool
instead.After this change, we can safely dispose
Resolver
instances. I looped over theNativeCodeGenState
instances disposing of eachResolver
at the end of the<GenerateJavaStubs/>
MSBuild task.