Uh oh!
There was an error while loading. Please reload this page.
Load Standalone GC correctly in component scenarios. - #120012
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a security vulnerability in standalone GC loading for .NET component scenarios (like C++/CLI). When APP_CONTEXT_BASE_DIRECTORY is empty in component scenarios, the GC library could be loaded from anywhere in the default search path, creating a potential security risk.
Key changes:
- Add validation to check if
APP_CONTEXT_BASE_DIRECTORYis an empty string - Skip the app base directory path when it's empty, forcing fallback to the coreclr binary directory
- Add explanatory comments about the component scenario behavior
Tagging subscribers to this area: @dotnet/gc |
AaronRobinsonMSFT
commented
Sep 24, 2025
/cc @dotnet/gc |
heh-ad
commented
Sep 29, 2025
Thanks for the fix, @AaronRobinsonMSFT . Could it be backported to .NET 10 as it impacts the upgrade to this LTS release? |
AaronRobinsonMSFT
commented
Sep 29, 2025
Would it be possible to use the more precise mechaism I mentioned at #119418 (comment)? Use |
AaronRobinsonMSFT
commented
Sep 29, 2025
/backport to release/10.0 |
AaronRobinsonMSFT
commented
Sep 29, 2025
/backport to release/9.0-staging |
Started backporting to release/10.0: https://github.com/dotnet/runtime/actions/runs/18112369317 |
Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/18112372375 |
heh-ad
commented
Sep 29, 2025
Thanks for the backporting, @AaronRobinsonMSFT . The reason that we have to use |
mangod9
commented
Sep 29, 2025
Is there a specific reason for using clrgc.dll? Are you still using segments based GC? |
heh-ad
commented
Sep 29, 2025
We are using clrgc.dll because the default GC implementation will reserve more than 200 GB memory for the managed heap. This makes our capacity tests reporting false regressions. With clrgc.dll, the results restore to the previous level. We are actually not aware other differences between the default GC and clrgc.dll. |
If its a memory reservation issue you can use the |
heh-ad
commented
Sep 30, 2025
Thanks @mangod9 . I tried the |
mangod9
commented
Sep 30, 2025
It's a static setting and the reservation size cannot be expanded. You should set it to something reasonable like the amount of physical memory on your VM/container. In |
heh-ad
commented
Sep 30, 2025
Thank you for the advice @mangod9. If the value is too big, then the capacity tests will still report false regressions. We will try to tune the value so that it will be enough and also be acceptable for the capacity tests. |
In .NET component scenarios (for example, C++/CLI), the
APP_CONTEXT_BASE_DIRECTORYproperty is set to an empty string. When the standalone GC scenario is exercised usingSystem.GC.NameorDOTNET_GCName, the empty directory is used as the path and the name appended to nothing. The result is for the load to use the default search path and could load the GC from anywhere. The solution is to useSystem.GC.PathorDOTNET_GCPathto get the desired behavior and we "fix" the component issue by going down the fallback path and use the same directory as thecoreclrbinary.Fixes#119418