[vlc-devel] [PATCH] access/qtsound: Fix race in qtsound close

Marvin Scholz epirat07 at gmail.com
Sun Jan 20 14:07:49 CET 2019


On 20 Jan 2019, at 10:04, Rémi Denis-Courmont wrote:

> Hi,
>
> Patch makes sense, but does the dispatched-to thread ever wait 
> directly or indirectly on the input thread to end? If so, this might 
> trigger a deadlock.
>

Thanks for bringing this up, this might indeed be a problem.

> Note that with or without the patch, depending on an unknown thread to 
> exist to run an access is a bad idea. I tried that approach with the 
> PulseAudio input and it lead to intractable deadlocks with the output. 
> Also, if a LibVLC app has no such thread, then nothing good can 
> happen.

Yeah, I wonder why it is done this way, I will check if this can just be 
done on the current
thread instead of dispatching to the main thread.

>
> Le 20 janvier 2019 05:36:26 GMT+02:00, Marvin Scholz 
> <epirat07 at gmail.com> a écrit :
>> Destruction of qtsound objects was dispatched async to the main 
>> thread,
>> this causes a race so that the qtsound objects can still be around 
>> when
>> the actual VLC objects those rely on are already gone (because Close
>> was
>> already left), causing weird crashes.
>>
>> Ref CD 0ee7a644-041f-453d-a196-7cdd75acaf3b
>> ---
>> modules/access/qtsound.m | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/modules/access/qtsound.m b/modules/access/qtsound.m
>> index 533d6e81344..ab44e12d777 100644
>> --- a/modules/access/qtsound.m
>> +++ b/modules/access/qtsound.m
>> @@ -504,9 +504,9 @@ static void Close(vlc_object_t *p_this)
>>         demux_t *p_demux = (demux_t*)p_this;
>>         demux_sys_t *p_sys = p_demux->p_sys;
>>
>> -        [p_sys->session
>> performSelectorOnMainThread:@selector(stopRunning) withObject:nil
>> waitUntilDone:NO];
>> -        [p_sys->audiooutput
>> performSelectorOnMainThread:@selector(release) withObject:nil
>> waitUntilDone:NO];
>> -        [p_sys->session 
>> performSelectorOnMainThread:@selector(release)
>> withObject:nil waitUntilDone:NO];
>> +        [p_sys->session
>> performSelectorOnMainThread:@selector(stopRunning) withObject:nil
>> waitUntilDone:YES];
>> +        [p_sys->audiooutput
>> performSelectorOnMainThread:@selector(release) withObject:nil
>> waitUntilDone:YES];
>> +        [p_sys->session 
>> performSelectorOnMainThread:@selector(release)
>> withObject:nil waitUntilDone:YES];
>>
>>         free(p_sys);
>>     }
>> -- 
>> 2.17.2 (Apple Git-113)
>>
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
>
> -- 
> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez 
> excuser ma brièveté._______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list