-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix race on DomainAssembly/Assembly/Module creation that results in incorrectly triggered ICorProfiler callbacks #120455
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
Conversation
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 race condition in the CoreCLR runtime that occurs during concurrent DomainAssembly/Assembly/Module creation, which could result in incorrectly triggered ICorProfiler callbacks. The fix introduces proper sequencing by deferring assembly object creation until after FileLoadLock creation.
- Adds a new
FILE_LOAD_ALLOCATEstage to theFileLoadLevelenum to represent when DomainAssembly and Assembly objects are allocated - Modifies FileLoadLock creation to initially have no associated Assembly, with the Assembly set later via a new
SetAssemblymethod - Updates the test project to trigger concurrent module loads that can reproduce the race condition
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/tests/profiler/unittest/moduleload.csproj | Adds reference to unloadlibrary project for concurrent testing |
| src/tests/profiler/unittest/moduleload.cs | Adds multi-threaded assembly loading test to trigger race conditions |
| src/coreclr/vm/assemblyspec.hpp | Adds FILE_LOAD_ALLOCATE enum value and updates comments |
| src/coreclr/vm/appdomain.hpp | Updates FileLoadLock interface to support deferred Assembly association |
| src/coreclr/vm/appdomain.cpp | Implements deferred Assembly creation and new allocation stage logic |
|
Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov |
jkotas
left a comment
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.
Thanks
Co-authored-by: Aaron Robinson <arobins@microsoft.com>
|
/backport to release/10.0 |
|
Started backporting to release/10.0: https://github.com/dotnet/runtime/actions/runs/18328456863 |
DomainAssembly/Assembly/Modulecreation until afterFileLoadLockcreationFILE_LOAD_ALLOCATEstage to theFileLoadLevelenum, representing the point at whichDomainAssemblyandAssemblyobjects are allocated and associated with the lock.FileLoadLockwithout an associatedAssemblyinitially. TheAssemblyis now set later, at the allocation stage, via the newSetAssemblymethod.moduleloadprofile test project to trigger concurrent module loads. It won't always hit the issue being fixed here, but should decently often (9/10 times when I ran locally).See #120296