[vlc-devel] commit: Warn in case of dangerous thread join patterns ( Rémi Denis-Courmont )

git version control git at videolan.org
Mon Jun 30 18:08:00 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Mon Jun 30 19:09:47 2008 +0300| [a417ec82d9a793a2681be75be9be719e4972cfce]

Warn in case of dangerous thread join patterns

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a417ec82d9a793a2681be75be9be719e4972cfce
---

 src/misc/objects.c |    5 +++++
 src/misc/threads.c |    3 +++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/misc/objects.c b/src/misc/objects.c
index ba58f71..a580116 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -301,7 +301,12 @@ static void vlc_object_destroy( vlc_object_t *p_this )
 
     /* If we are running on a thread, wait until it ends */
     if( p_priv->b_thread )
+    {
+        msg_Warn (p_this->p_libvlc, /* do NOT use a dead object for logging! */
+                  "object %d destroyed while thread alive (VLC might crash)",
+                  p_this->i_object_id);
         vlc_thread_join( p_this );
+    }
 
     /* Call the custom "subclass" destructor */
     if( p_priv->pf_destructor )
diff --git a/src/misc/threads.c b/src/misc/threads.c
index bd23b3a..9bb111b 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -695,7 +695,10 @@ void __vlc_thread_join( vlc_object_t *p_this, const char * psz_file, int i_line
     /* Make sure we do return if we are calling vlc_thread_join()
      * from the joined thread */
     if (pthread_equal (pthread_self (), p_priv->thread_id))
+    {
+        msg_Warn (p_this, "joining the active thread (VLC might crash)");
         i_ret = pthread_detach (p_priv->thread_id);
+    }
     else
         i_ret = pthread_join (p_priv->thread_id, NULL);
 




More information about the vlc-devel mailing list