pti-gpu icon indicating copy to clipboard operation
pti-gpu copied to clipboard

windows oneprof atexit issues

Open gbergsch opened this issue 2 years ago • 1 comments

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.

gbergsch avatar Feb 28 '23 17:02 gbergsch

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.

ph0b avatar Dec 07 '23 14:12 ph0b

@gbergsch Please use unitrace. oneprof is not supported any more.

zma2 avatar Aug 01 '25 20:08 zma2