From 96e83f95eef5be8e1f64a1a2e61810cb7b82ff5c Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 29 Jul 2016 08:02:02 -0700 Subject: Don't try freeing the context in ReleaseThreadCtx Unfortunately on certain systems, the TLS callback is called in a restricted context, and isn't allowed to access certain messaging sub-systems. Such sub- systems may be used if the thread's context is freed, in turn freeing the device, which it tries to close. Ideally, the app shouldn't have tried to destroy a context while it was still current on a thread, or even leave a context current on a thread that's being destroyed,. So for now, release the context ref and print an ERR that it might be leaked. --- Alc/ALc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Alc/ALc.c') diff --git a/Alc/ALc.c b/Alc/ALc.c index 9d3553c8..b6192317 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -2376,23 +2376,23 @@ static void ReleaseContext(ALCcontext *context, ALCdevice *device) void ALCcontext_IncRef(ALCcontext *context) { - uint ref; - ref = IncrementRef(&context->ref); + uint ref = IncrementRef(&context->ref); TRACEREF("%p increasing refcount to %u\n", context, ref); } void ALCcontext_DecRef(ALCcontext *context) { - uint ref; - ref = DecrementRef(&context->ref); + uint ref = DecrementRef(&context->ref); TRACEREF("%p decreasing refcount to %u\n", context, ref); if(ref == 0) FreeContext(context); } static void ReleaseThreadCtx(void *ptr) { - WARN("%p current for thread being destroyed\n", ptr); - ALCcontext_DecRef(ptr); + ALCcontext *context = ptr; + uint ref = DecrementRef(&context->ref); + TRACEREF("%p decreasing refcount to %u\n", context, ref); + ERR("Context %p current for thread being destroyed, possible leak!\n", context); } /* VerifyContext -- cgit v1.2.3