Skip to content

Commit 7229c7c

Browse files
[release/10.0] Fix removing module from appdomain in DB_IPCE_UNLOAD_MODULE event (#124241)
Backport of #123931 to release/10.0 /cc @hoyosjs @tommcdon ## Customer Impact - [X] Customer reported - [ ] Found internally When loading and unloading an Assembly multiple times in new AssemblyLoadContexts Visual Studio will abruptly end debugging before program completion with the following error: > A fatal error has occurred and debugging needs to be terminated. For more details, please see the Microsoft Help and Support web site. HRESULT=0x80131c36. ErrorCode=0x0. Originally reported via Visual Studio feedback item [Fatal error encountered when debugging .net 10 app using collectible assemblies in VS2026](https://developercommunity.visualstudio.com/t/Fatal-error-encountered-when-debugging-/10982926), then moved to GH issue #123930. ## Regression - [X] Yes - [ ] No Regression from .NET 9, introduced in .NET 10 on #117224 and was a missed case when attempting to address the issue in #118414. ## Testing Validated with customer's reproducible test case on #123930 ## Risk Low. The debugger module caches uses the module as the hash key rather than the assembly. This was a missed case when fixing #118414 where we were still incorrectly using the assembly as the lookup key. Co-authored-by: Tom McDonald <tommcdon@microsoft.com>
1 parent 190c0c2 commit 7229c7c

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/coreclr/debug/di/module.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ void DbgAssertModuleDeletedCallback(VMPTR_DomainAssembly vmDomainAssembly, void
117117
//
118118
void CordbModule::DbgAssertModuleDeleted()
119119
{
120-
GetProcess()->GetDAC()->EnumerateModulesInAssembly(
121-
m_pAssembly->GetDomainAssemblyPtr(),
120+
GetProcess()->GetDAC()->EnumerateAssembliesInAppDomain(
121+
m_pAppDomain->GetADToken(),
122122
DbgAssertModuleDeletedCallback,
123123
this);
124124
}

src/coreclr/debug/di/process.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5225,7 +5225,7 @@ void CordbProcess::RawDispatchEvent(
52255225
pCallback1->UnloadModule(pAppDomain, module);
52265226
}
52275227

5228-
pAppDomain->m_modules.RemoveBase(VmPtrToCookie(pEvent->UnloadModuleData.vmDomainAssembly));
5228+
pAppDomain->m_modules.RemoveBase(VmPtrToCookie(module->m_vmModule));
52295229
}
52305230
break;
52315231

0 commit comments

Comments
 (0)