This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Remove shutdown attempt on Windows process detach
ClosedPublic

Authored by jlpeyton on Feb 15 2021, 9:54 PM.

Details

Summary

Only attempt shutdown if lpReserved is NULL. The Windows documentation states:

When handling DLL_PROCESS_DETACH, a DLL should free resources such as heap memory only if the DLL is being unloaded dynamically (the lpReserved parameter is NULL). If the process is terminating (the lpReserved parameter is non-NULL), all threads in the process except the current thread either have exited already or have been explicitly terminated by a call to the ExitProcess function, which might leave some process resources such as heaps in an inconsistent state. In this case, it is not safe for the DLL to clean up the resources. Instead, the DLL should allow the operating system to reclaim the memory.

Hence, don't bother with a "proper" shutdown and let the OS take care of resources when terminating the process vs. unloading DLL.

Diff Detail

Event Timeline

jlpeyton created this revision.Feb 15 2021, 9:54 PM
jlpeyton requested review of this revision.Feb 15 2021, 9:54 PM
hbae accepted this revision.Feb 21 2021, 11:45 AM

LGTM

This revision is now accepted and ready to land.Feb 21 2021, 11:45 AM