[PATCH] quartz: Increment reference count for the advise thread to avoid crashes caused by DLL unloading.

Zebediah Figura (she/her) zfigura at codeweavers.com
Tue Aug 10 17:51:49 CDT 2021

Hello Hiroki, thanks for the patch!

On 8/10/21 5:38 PM, Hiroki Awata wrote:
> Some games crash when the DLL is unloaded during SleepConditionVariableCS on SystemClockAdviseThread.
> This is due to the fact that DllCanUnloadNow returns S_OK even though the advise thread is running.
> Incrementing the reference count when creating the advise thread resolves it.

This doesn't seem right; the system clock object itself should be 
holding a reference [added by DSCF_CreateInstance(), removed by 
system_clock_inner_Release()] and waits for the thread to stop before 
removing it. Are you sure we're not leaking a reference elsewhere?

More information about the wine-devel mailing list