runtime: Test failure: Loader\\CollectibleAssemblies\\ResolvedFromDifferentContext\\ResolvedFromDifferentContext\\ResolvedFromDifferentContext.cmd
Assert failure(PID 5456 [0x00001550], Thread: 10976 [0x2ae0]): refRetVal->GetAt(i) != NULL
CORECLR! RuntimeTypeHandle::GetInterfaces + 0x4A8 (0x00007ffba633e958) SYSTEM.PRIVATE.CORELIB! <no symbol> + 0x0 (0x00007ffba5a12078)
SYSTEM.PRIVATE.CORELIB! <no symbol> + 0x0 (0x00007ffba5a0f9f8) SYSTEM.PRIVATE.CORELIB! <no symbol> + 0x0 (0x00007ffba5a0f634)
SYSTEM.PRIVATE.CORELIB! <no symbol> + 0x0 (0x00007ffba5546958) <no module>! <no symbol> + 0x0 (0x00007ffb46b42924)
File: D:\a_work\1\s\src\coreclr\vm\runtimehandles.cpp Line: 785
Image: D:\h\w\BB20096C\p\corerun.exe
Return code: 1
Raw output file: D:\h\w\BB20096C\w\A3480908\uploads\Reports\Loader.CollectibleAssemblies\ResolvedFromDifferentContext\ResolvedFromDifferentContext\ResolvedFromDifferentContext.output.txt
Raw output:
BEGIN EXECUTION
"D:\h\w\BB20096C\p\corerun.exe" -p "System.Reflection.Metadata.MetadataUpdater.IsSupported=false" ResolvedFromDifferentContext.dll
Running test case LoadOverride
Loading TestInterface by alc "Dependencies" System.Runtime.Loader.AssemblyLoadContext #1 for alc "Test2" TestAssemblyLoadContext #0
Load done, type TestClass.Class obtained
Expected: 100
Actual: -1073740286
END EXECUTION - FAILED
FAILED
Test Harness Exitcode is : 1
To run the test:
set CORE_ROOT=D:\h\w\BB20096C\p
D:\h\w\BB20096C\w\A3480908\e\Loader\CollectibleAssemblies\ResolvedFromDifferentContext\ResolvedFromDifferentContext\ResolvedFromDifferentContext.cmd
Expected: True
Actual: False
Fails for: coreclr windows arm64 Checked gcstress0x3 coreclr Linux arm Checked gcstress0x3 coreclr OSX arm64 Checked gcstress0x3 coreclr Linux arm64 Checked gcstress0x3 coreclr Linux arm64 Checked gcstress0xc coreclr Linux x64 Checked gcstress0xc
Also fails with a different message:
Assert failure(PID 3348 [0x00000d14], Thread: 3084 [0x0c0c]): Postcondition failure: FAILED: GetWriteableData()->m_hExposedClassObject != 0
CORECLR! CHECK::Trigger + 0x2D1 (0x00007fffe310c1d1) CORECLR! MethodTable::GetManagedClassObject + 0x1B6 (0x00007fffe2b640d6)
CORECLR! RuntimeTypeHandle::GetInterfaces + 0x5BF (0x00007fffe2eae72f) SYSTEM.PRIVATE.CORELIB! <no symbol> + 0x0 (0x00007fffe22c8ac0)
SYSTEM.PRIVATE.CORELIB! <no symbol> + 0x0 (0x00007fffe22c6f04) SYSTEM.PRIVATE.CORELIB! <no symbol> + 0x0 (0x00007fffe22c6c54)
SYSTEM.PRIVATE.CORELIB! <no symbol> + 0x0 (0x00007fffe1f9309f) <no module>! <no symbol> + 0x0 (0x00007fff837f2686)
<no module>! <no symbol> + 0x0 (0x000001de5dca8d20) <no module>! <no symbol> + 0x0 (0x000001de56f0a4d0)
File: D:\a_work\1\s\src\coreclr\vm\methodtable.cpp Line: 3629
Image: C:\h\w\B611097B\p\corerun.exe
Return code: 1
Raw output file: C:\h\w\B611097B\w\A0D70927\uploads\Reports\Loader.CollectibleAssemblies\ResolvedFromDifferentContext\ResolvedFromDifferentContext\ResolvedFromDifferentContext.output.txt
Raw output:
BEGIN EXECUTION
"C:\h\w\B611097B\p\corerun.exe" -p "System.Reflection.Metadata.MetadataUpdater.IsSupported=false" ResolvedFromDifferentContext.dll
Running test case LoadOverride
Loading TestInterface by alc "Dependencies" System.Runtime.Loader.AssemblyLoadContext #1 for alc "Test2" TestAssemblyLoadContext #0
Load done, type TestClass.Class obtained
Expected: 100
Actual: -1073740286
END EXECUTION - FAILED
FAILED
Test Harness Exitcode is : 1
To run the test:
set CORE_ROOT=C:\h\w\B611097B\p
C:\h\w\B611097B\w\A0D70927\e\Loader\CollectibleAssemblies\ResolvedFromDifferentContext\ResolvedFromDifferentContext\ResolvedFromDifferentContext.cmd
Expected: True
Actual: False
for: coreclr windows x64 Checked gcstress0x3 coreclr windows x86 Checked gcstress0x3
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (16 by maintainers)
So I have a full understanding of how we get into the problematic state. The key thing is how the test loads the interface assembly. It creates the collectible ALC1 inside of the ALC.Load method of the other collectible ALC2, loads the interface assembly using that and returns the resulting assembly from the Load method. So when it returns, there are no more references to that ALC1. There is still a reference to the managed
LoaderAllocatorof that ALC1 from the managed Assembly instance, however, that managed assembly instances is only referenced in theRuntimeInvokeHostAssemblyResolverthat invoked the managed code to load the assembly. Once we return from that function, the reference to that managed Assembly is gone too. At the time we return back toAppDomain::BindAssemblySpecand callAppDomain::AddFileToCachefrom there, we’ve already performed at least a couple of GC collections, so both the managed Assembly and the managedLoaderAllocatorare already collected. And that’s the point where we are adding reference between the nativeLoaderAllocators of the parent and resolved assembly and due to the sequence of events, we don’t have the managedLoaderAllocatoranymore.One way to fix that issue may be to move adding the reference between the native
LoaderAllocators up to theRuntimeInvokeHostAssemblyResolverfunction where we still have the reference to the just loaded managed Assembly. Interestingly enough, that’s a place where I had it originally, but I’ve ended up moving it to the common place inAppDomain::AddFileToCacheafter consulting it with @vitek-karas. It looked like a good idea at that time.