dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.55k stars 4.54k forks source link

[Mono] Unloadable ALCs. #79711

Open lateralusX opened 1 year ago

lateralusX commented 1 year ago

https://github.com/dotnet/runtime/pull/77399 setup basic support for unloadable ALCs in Mono. This issue tracks remaining work to complete unloadable ALCs on Mono runtime. Initial list of work items is extracted from https://github.com/dotnet/runtime/blob/main/docs/design/mono/unloadability.md#remaining-work:

Must

Should

Could

dotnet-issue-labeler[bot] commented 1 year ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

ghost commented 1 year ago

Tagging subscribers to this area: See info in area-owners.md if you want to be subscribed.

Issue Details
https://github.com/dotnet/runtime/pull/77399 setup basic support for unloadable ALCs in Mono. This issue tracks remaining work to complete unloadable ALCs on Mono runtime. Initial list of work items is extracted from https://github.com/dotnet/runtime/blob/main/docs/design/mono/unloadability.md#remaining-work: ## Must - [ ] Managed frames. Frames belonging to code in the ALC should keep the ALC alive. This can be implemented by having all methods allocate a volatile local variable and store a reference to their LoaderAllocator object into it. - [ ] Reflection pointers. Icalls which take a assembly/type etc. handle as parameter need to keep the ALC alive, otherwise there will be subtle races. - [ ] TLS variables. - [ ] Testing and leak detection. - [ ] Enable/disable compiler flag. ##Should - [ ] Thread abort. Although its not part of current .NET APIs, it might be useful to have a way to abort threads executing code in an ALC, similarly to how domain unloads worked previously. - [ ] Profiling, perf counters, etc. - [ ] Diagnostics support, i.e. what keeps an ALC alive. ##Could - [ ] Boehm GC support.
Author: lateralusX
Assignees: -
Labels: `untriaged`, `area-AssemblyLoader-mono`
Milestone: -
teo-tsirpanis commented 1 year ago

abort threads executing code in an ALC, similarly to how domain unloads worked previously.

Note that forceful unloading of ALCs is an explicit non-goal and generally frowned upon for the same reason Thread.Abort is bad. Are you sure you want it?

teo-tsirpanis commented 1 year ago

@steveisok what is the milestone for this? untriaged means without a milestone and gets automatically removed by the bot.

lateralusX commented 1 year ago

abort threads executing code in an ALC, similarly to how domain unloads worked previously.

Note that forceful unloading of ALCs is an explicit non-goal and generally frowned upon for the same reason Thread.Abort is bad. Are you sure you want it?

Fully aware on existing unload design and Thread.Abort impact and it has been discussed over last years in various forms. This issue might not be the right form to carry additional/new "ideas" and it's generally not something we would just implement, but since we have many customers that tries to mitigate the lack of app domains (Unity is one example) we also work on ideas going forward on how to simplify/assist developers with existing scenarios/solutions relying on aspects of app domains to move over to dotnet runtime. I removed the Thread.Abort from this issue since it falls into a wider discussion and not directly needed for Mono ALC support.

srxqds commented 1 year ago

abort threads executing code in an ALC, similarly to how domain unloads worked previously.

Note that forceful unloading of ALCs is an explicit non-goal and generally frowned upon for the same reason Thread.Abort is bad. Are you sure you want it?

@lateralusX @teo-tsirpanis this is most import for embed reload process, hope you can consider adding this.

SamMonoRT commented 10 months ago

@vargaz @lateralusX - moving this to 9.0.0 milestone.

MichalPetryka commented 4 months ago

99072 implements AllocateTypeAssociatedMemory by making it never freed, this will need to be changed when unloadable ALCs start to be supported in Mono.

srxqds commented 3 months ago

hi, any update for this?

newNcy commented 3 months ago

hi, any update for this?

哥 交流下?

srxqds commented 2 weeks ago

hi, is there any progress or plan?