[vlc-devel] [PATCH] -- core(update.c) : correct object release misplaced and memory leaks

Rémi Denis-Courmont remi at remlab.net
Mon Aug 3 14:57:34 CEST 2009


On Mon, 3 Aug 2009 14:09:33 +0200, Rafaël Carré <rafael.carre at gmail.com>
wrote:
> There seems to be no problem with a thread destroying the object it is
> associated to (there is no crash if you remove this assertion).

There is a major problem. The thread handle is hidden inside the object. So
once the object is destroyed, you cannot refer to the thread. Then you
cannot join the thread. Then you leak its whole call stack and any other
internal run-time data behind the thread handle.

Also, from a more practical perspective, this would crash at
src/misc/threads.c:58, if not earlier.

> Perhaps the assertion could check if the running thread is the caller
> of vlc_object_destroy?

No. Use vlc_clone() instead of vlc_thread_create(); then you can store the
vlc_thread_t handle somewhere outside of the destroyed VLC object
structure. You still need to ensure that the thread won't use any
underlying LibVLC subsystem after it's been halted. For instance, you
probably need to exit before message queues are terminated.

-- 
Rémi Denis-Courmont




More information about the vlc-devel mailing list