[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 20:22:58 CDT 2021


On 8/10/21 7:18 PM, 粟田大樹 wrote:
> Hi, Zebediah.
> Thanks for the detailed research.
> I've revert the first patch, applied the next one and the test was
> successful!
> Is the code fix as intended? If it is ok, I will send a PATCH v2.
> 
> diff --git a/dlls/quartz/systemclock.c b/dlls/quartz/systemclock.c
> index 73a923a7b99..0eb339420db 100644
> --- a/dlls/quartz/systemclock.c
> +++ b/dlls/quartz/systemclock.c
> @@ -338,6 +338,7 @@ HRESULT system_clock_create(IUnknown *outer, IUnknown
> **out)
>       list_init(&object->sinks);
>       InitializeCriticalSection(&object->cs);
>       object->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ":
> SystemClockImpl.cs");
> +    InterlockedIncrement(&object_locks);
> 
>       TRACE("Created system clock %p.\n", object);
>       *out = &object->IUnknown_inner;
> 

Well, it's not quite as simple as that hunk; now you're leaking 
references for any system clock created via CoCreateInstance(). You'll 
need to do the same for all other quartz objects, and remove the 
InterlockedIncrement() from DSCF_CreateInstance().



More information about the wine-devel mailing list