[vlc-devel] commit: Do NOT use msg_* functions AFTER the messagebank has been destroyed . (Jean-Paul Saman )

git version control git at videolan.org
Mon Oct 27 16:23:27 CET 2008


vlc | branch: 0.8.6-bugfix | Jean-Paul Saman <jpsaman at videolan.org> | Tue Oct 21 10:44:32 2008 +0200| [20a9560bf514c2dc67e3996f695273f24d2aa04c] | committer: Jean-Paul Saman 

Do NOT use msg_* functions AFTER the messagebank has been destroyed.

In src/libvlc.c VLC_Destroy() function various vlc_*_destroy() functions were called that used msg_{Err,Dbg,Info,Warn} while the message bank and queues where already destroyed. It caused various crashes in vlc's webplugins.

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

 include/vlc_threads_funcs.h |    6 +++---
 src/misc/objects.c          |   12 ++++++------
 src/misc/threads.c          |   20 ++++++++------------
 src/misc/variables.c        |    4 +++-
 4 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/include/vlc_threads_funcs.h b/include/vlc_threads_funcs.h
index 9b76449..7cd9a33 100644
--- a/include/vlc_threads_funcs.h
+++ b/include/vlc_threads_funcs.h
@@ -3,7 +3,7 @@
  * This header provides a portable threads implementation.
  *****************************************************************************
  * Copyright (C) 1999, 2002 the VideoLAN team
- * $Id$
+ * $Id: 9b7644900d63637882cf751fbdef2f1a5d6a3f5a $
  *
  * Authors: Jean-Marc Dressler <polux at via.ecp.fr>
  *          Samuel Hocevar <sam at via.ecp.fr>
@@ -119,7 +119,7 @@ static inline int __vlc_mutex_lock( const char * psz_file, int i_line,
 
     if( i_result )
     {
-        msg_Err( p_mutex->p_this,
+        fprintf( stderr,
                  "mutex_lock failed at %s:%d (%d:%s)",
                  psz_file, i_line, i_result, psz_error );
     }
@@ -188,7 +188,7 @@ static inline int __vlc_mutex_unlock( const char * psz_file, int i_line,
 
     if( i_result )
     {
-        msg_Err( p_mutex->p_this,
+        fprintf( stderr,
                  "mutex_unlock failed at %s:%d (%d:%s)",
                  psz_file, i_line, i_result, psz_error );
     }
diff --git a/src/misc/objects.c b/src/misc/objects.c
index 2478612..3792117 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -344,14 +344,14 @@ void __vlc_object_destroy( vlc_object_t *p_this )
 
     if( p_this->i_children )
     {
-        msg_Err( p_this, "cannot delete object (%i, %s) with children" ,
+        fprintf( stderr, "cannot delete object (%i, %s) with children" ,
                  p_this->i_object_id, p_this->psz_object_name );
         return;
     }
 
     if( p_this->p_parent )
     {
-        msg_Err( p_this, "cannot delete object (%i, %s) with a parent",
+        fprintf( stderr, "cannot delete object (%i, %s) with a parent",
                  p_this->i_object_id, p_this->psz_object_name );
         return;
     }
@@ -363,21 +363,21 @@ void __vlc_object_destroy( vlc_object_t *p_this )
         /* Don't warn immediately ... 100ms seems OK */
         if( i_delay == 2 )
         {
-            msg_Warn( p_this,
+            fprintf( stderr,
                   "refcount is %i, delaying before deletion (id=%d,type=%d)",
                   p_this->i_refcount, p_this->i_object_id,
                   p_this->i_object_type );
         }
         else if( i_delay == 10 )
         {
-            msg_Err( p_this,
+            fprintf( stderr,
                   "refcount is %i, delaying again (id=%d,type=%d)",
                   p_this->i_refcount, p_this->i_object_id,
                   p_this->i_object_type );
         }
         else if( i_delay == 20 )
         {
-            msg_Err( p_this,
+            fprintf( stderr,
                   "waited too long, cancelling destruction (id=%d,type=%d)",
                   p_this->i_object_id, p_this->i_object_type );
             return;
@@ -603,7 +603,7 @@ void __vlc_object_detach( vlc_object_t *p_this )
     vlc_mutex_lock( &structure_lock );
     if( !p_this->p_parent )
     {
-        msg_Err( p_this, "object is not attached" );
+        fprintf( stderr, "object is not attached" );
         vlc_mutex_unlock( &structure_lock );
         return;
     }
diff --git a/src/misc/threads.c b/src/misc/threads.c
index f7142c9..675c29b 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -26,6 +26,7 @@
 #include <vlc/vlc.h>
 
 #include <stdlib.h>
+#include <assert.h>
 
 #define VLC_THREADS_UNINITIALIZED  0
 #define VLC_THREADS_PENDING        1
@@ -354,12 +355,11 @@ int __vlc_mutex_destroy( char * psz_file, int i_line, vlc_mutex_t *p_mutex )
 
 #endif
 
-    if( i_result )
-    {
-        msg_Err( p_mutex->p_this,
-                 "thread %d: mutex_destroy failed at %s:%d (%d:%s)",
-                 i_thread, psz_file, i_line, i_result, psz_error );
-    }
+    /* DO NOT USE ANY msg_* functions here, since it can
+       be called when the message subsystem has been destroyed
+       (msg_Destroy() has been called). */
+    assert( i_result == 0 );
+
     return i_result;
 }
 
@@ -503,12 +503,8 @@ int __vlc_cond_destroy( char * psz_file, int i_line, vlc_cond_t *p_condvar )
 
 #endif
 
-    if( i_result )
-    {
-        msg_Err( p_condvar->p_this,
-                 "thread %d: cond_destroy failed at %s:%d (%d:%s)",
-                 i_thread, psz_file, i_line, i_result, psz_error );
-    }
+    assert( i_result == 0 );
+
     return i_result;
 }
 
diff --git a/src/misc/variables.c b/src/misc/variables.c
index 3784539..96ae881 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -1080,7 +1080,9 @@ static int GetUnused( vlc_object_t *p_this, const char *psz_name )
 
         if( i_tries++ > 100 )
         {
-            msg_Err( p_this, "caught in a callback deadlock?" );
+            /* NOTE: this function might be called AFTER message bank
+               has been destroyed */
+            fprintf( stderr, "caught in a callback deadlock?" );
             return VLC_ETIMEOUT;
         }
 




More information about the vlc-devel mailing list