Please sign in to comment.
3rdparty/pthreads4w: Fixup process exit logic. (#3056)
This PR modifies a third party module - I realize normally those should be fixed upstream, but I really doubt pthreads4w would a) consider it a valid bug and b) fix it. To make all my changes easily visible, I wrap them all in #if PCSX2_FIX. This PR fixes a process exit routine in pthreads. This third party module exploits CRT initialization order to inject their initializer/deinitializer earlier than the others by putting their functions in .CRT$XCU and .CRT$XPU pseudo regions. The problem comes when a module gets build with dynamic CRT (/MD or /MDd), like most of PCSX2 plugins, it doesn't actually use .CRT$XPx regions as terminators, and instead lets dynamic CRT handle them. This PR corrects this issue by registering the terminator via atexit, so it works with both static and dynamic CRT. This resolves an issue where SPU2-X plugin (and potentially more) leaks TLS handles when unloaded.
- Loading branch information...