Skip to content
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

windows oneprof atexit issues #29

Open
gbergsch opened this issue Feb 28, 2023 · 1 comment
Open

windows oneprof atexit issues #29

gbergsch opened this issue Feb 28, 2023 · 1 comment

Comments

@gbergsch
Copy link

The methodology of running finalize at oneprof DLL unload on windows is fundamentally broken. It assumes access to the L0 runtime library, but microsoft explicitly warns against any other DLL dependency at exit. It regularly causes a segfault.

I've tried various dll hacks to attempt to work around it, but ultimately I think we will need to do finalize when the CL/L0 context is destroyed via layer intercept when we know the DLL is still loaded.

There are also other issues with deconstructors during DLL unload such as https://github.com/intel/pti-gpu/blob/master/tools/oneprof/metric_streamer_collector.h#L88 which causes fault as well when the L0 driver is already unloaded.

@ph0b
Copy link

ph0b commented Dec 7, 2023

Some relevant documentation: https://learn.microsoft.com/en-us/windows/win32/dlls/dllmain

If the process is terminating (the lpvReserved 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.

In case of process termination, little finalization can be done since heap may be in inconsistent state and other DLLs dependencies already unloaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants