[vlc-devel] fix #14586 (6f3e18d5) leads to crash on Android

Andrey Gursky andrey.gursky at e-mail.ua
Sun May 29 21:42:36 CEST 2016


On Sun, 29 May 2016 20:48:34 +0200
Andrey Gursky <andrey.gursky at e-mail.ua> wrote:

> On Sun, 29 May 2016 21:43:38 +0300
> Rémi Denis-Courmont <remi at remlab.net> wrote:
> 
> > On Sunday 29 May 2016 20:31:37 Andrey Gursky wrote:
> > > considering src/android/thread.c:
> > > 
> > > static __thread struct vlc_thread *thread = NULL;
> > > 
> > > vlc_thread_t vlc_thread_self (void)
> > > {
> > >     return thread;
> > > }
> > > 
> > > void vlc_control_cancel(int cmd, ...)
> > > {
> > >     vlc_thread_t th = vlc_thread_self();
> > >     va_list ap;
> > > //...
> > > }
> > > 
> > > I don't see where this TLS variable "thread" is assigned before call to
> > > vlc_control_cancel().
> > 
> > TBH, that it´s not hard to find by looking for "thread =", and it has not 
> > changed in 3 years.
> 
> Yes, I did that, of course. From what I found, it doesn't get assigned.

Looking further, it seems to be assigned at thread creation if the
thread has been created with vlc_clone() (i.e. joinable):
vlc_clone()
    vlc_clone_attr()
        joinable_thread()
            vlc_cleanup_push(finish_joinable_thread, th);
            thread = th;

But what if vlc_join() will be called on a detached thread? The
documentation doesn't specify, what would happen in this case:
------------------------------------------------------------------------
include/vlc_threads.h:
/**
 * Waits for a thread to complete (if needed), then destroys it.
 *
 * \note This is a cancellation point. In case of cancellation, the thread is
 * <b>not</b> joined.

 * \warning A thread cannot join itself (normally VLC will abort if this is
 * attempted). Also a detached thread <b>cannot</b> be joined.
 *
 * @param th thread handle
 * @param result [OUT] pointer to write the thread return value or NULL
 */
VLC_API void vlc_join(vlc_thread_t th, void **result);
-------------------------------------------------------------------------

In contrast, the man page for pthread_join() is clear:
--------------------------------------------------------------------------
The pthread_join() function waits for the thread specified by thread
to terminate.  If that thread has already terminated, then pthread_join()
returns immediately.  The thread specified by thread must be joinable.
--------------------------------------------------------------------------

Regards,
Andrey


More information about the vlc-devel mailing list