-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Can the CoreCLR library be unloaded from the memory process? #8350
Comments
CoreCLR.so/dll does not support unloading. |
This makes sense, but coreruncommon.cpp tries to unload it: Is that a bug? |
Yes, the dlclose call should be removed. |
Is at least unloading the (one and only) AppDomain legal? |
The "unload" of the one and only AppDomain will just deliver the callbacks like AppDomain.ProcessExit. It won't actually kill the appdomain. |
So I understand there is no memory gain in calling UnloadAppDomain or coreclr_shutdown, right? By the way this is the behavior I see:
Thank you again |
Right.
coreclr_shutdown calls UnloadAppDomain. It is surprising that coreclr_shutdown works for you, but UnloadAppDomain does not.
This entry point was added for .NET Core 2.0. Are you using recent .NET Core 2.0 builds? |
It surprised me too, but substantially I have created two projects calling either the Windows specific code or the portable one. The layout of the calls are substantially the same and I am not mixing the APIs of course.
I am using the official 2.0 preview, therefore it is definitely possible the coreclr_shutdown_2 was added later. |
@raffaeler Are you able to find coreclr_shutdown_2 in latest build? It should be shipped with .NET Core 2.0 preview. |
@jkotas May I ask why unloading is not supported? Is it because there is no way to shutdown background threads cleanly? |
Yes, cleaning up everything reliably is hard: shutdown all thread, free all memory, unregister all callbacks, ... . |
Not sure which area this belongs to. Feel free to change. |
I'm writing a plugin which uses coreclr to call into a managed assembly. I'm having an issue when the program that uses my plugin tries to exit it hangs, even when I call coreclr_shutdown in my plugin and I believe this issue is related. Is there a workaround I could use? Edit: This is on a self-built x86 Linux debug build. |
Could you please attach debugger and find our where does it hang? |
the effected line is; m_mutex is is a pthread_mutex_t |
Is LinuxPipeThread code that you have written? I do not think we have anything like that in CoreCLR. |
It's code contained by the program that is using my plugin (it's not my code nor is it from CoreCLR). The code in question is here https://github.com/PCSX2/pcsx2/blob/1.4.x/pcsx2/Linux/LnxConsolePipe.cpp Edit: I've also not posted the full call stack, I didn't think anything beyond what I included was usefull |
It does not look like a problem with CoreCLR or related to this issue from what you have shared so far. You need to debug the LinuxPipeThread code and figure our what it is waiting for. |
You have to excuse me, I'm not particularly well versed in debugging multithreaded programs. The thread that is blocking is a stderr redirect thread (PCSX2 replaces stdout/stderr with pipes) Figuring this out forced me to learn how to better debug multi-threaded applications better. Call stacks below at the time of the hang;
|
Update: As I mentioned earlier the code in LinuxPipeThread replaces stdout/stderr with pipes During destruction, the read file descriptor is closed and waits for the read threads to exit (which they quickly do as it reaches eof of the pipe) However, CoreCLR create an extra set of file descriptors for the stdout/stderr pipes and keeps them open even after coreclr_shutdown has been called, causing the read threads in LinuxPipeThread to continue running, hanging the process. If I forcible close the extra descriptors (by searching though the data returned from getdtablesize()), the hang dosn't occur and the program closes normally, confirming that it's the extra file descriptors opened by CoreCLR that is causing the hang. |
* wasm: add support for most of the conv_ovf operations i and i_un still to do. * correct comment * remove masks, refactor * address feedback. Refactor to remove some conditions. Change Dbl2ULngOvf to check for negative
This issue is tracked by: #25394 |
I host the CoreCLR by myself.
Since I wrapped the "LoadLibrary / FreeLibrary" "dlopen / dlclose" in a C++ class using the RAII paradigm, at the very end my app tries to unload the CLR and crashes.
This happens with both Windows specific API (mscoree) and with platform-neutral API (coreclr_initialize & Co).
If I comment out the coreclr unloading, everything works fine and the process closes normally.
What is the rationale behind the CoreCLR library? Can it be unloaded from the process or should I avoid unloading it?
The text was updated successfully, but these errors were encountered: