-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Test for unloadable ALC frees file lock #120066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test for unloadable ALC frees file lock #120066
Conversation
Remove extra AddRef() to remove file lock of DLL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a file lock issue with unloadable AssemblyLoadContext by removing an unnecessary AddRef() call in the CoreCLR VM. The fix prevents loaded assemblies from holding file locks after their AssemblyLoadContext has been unloaded, which was causing the issue described in GitHub #119647.
Key changes:
- Removes extra
AddRef()call that was preventing proper cleanup of file handles - Moves assembly validation to occur during Assembly creation rather than DomainAssembly construction
- Adds comprehensive test to verify file locks are properly released after ALC unload
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/tests/Loader/CollectibleAssemblies/AssemblyOnDisk/Program.cs | New test that verifies file locks are released after unloading collectible AssemblyLoadContext |
| src/tests/Loader/CollectibleAssemblies/AssemblyOnDisk/AssemblyOnDisk.csproj | Test project configuration with required isolation settings |
| src/coreclr/vm/domainassembly.cpp | Removes unnecessary AddRef() call and moves validation logic |
| src/coreclr/vm/assembly.hpp | Makes Assembly constructor private for better encapsulation |
| src/coreclr/vm/assembly.cpp | Moves PEAssembly validation to Assembly::Create and updates CONTRACTL macros |
|
Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
src/tests/Loader/CollectibleAssemblies/AssemblyOnDisk/Program.cs
Outdated
Show resolved
Hide resolved
|
This needs to be ported to .NET 10. |
|
Test failures look related |
|
/backport to release/10.0 |
|
Started backporting to release/10.0: https://github.com/dotnet/runtime/actions/runs/18022983560 |
Remove extra
AddRef()to remove file lock on DLL.Fixes #119647