Changeset 5bd06c4b174082d6062e267565342c568ba6454d

Show
Ignore:
Timestamp:
30/08/08 09:21:45 (3 months ago)
Author:
Rémi Denis-Courmont <rdenis@simphalempin.com>
git-committer:
Rémi Denis-Courmont <rdenis@simphalempin.com> 1220080905 +0300
git-parent:

[a6b444838032d8efb86e28fc0391c68909d4f2b2]

git-author:
Rémi Denis-Courmont <rdenis@simphalempin.com> 1220080881 +0300
Message:

Remove the broken reference checker

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/libvlc.h

    rd6c0f24 r5bd06c4  
    4747void vlc_threads_end( void ); 
    4848vlc_object_t *vlc_threadobj (void); 
    49 #ifdef LIBVLC_REFCHECK 
    50 void vlc_refcheck (vlc_object_t *obj); 
    51 #else 
    52 # define vlc_refcheck( obj ) (void)0 
    53 #endif 
    5449 
    5550/* Hopefully, no need to export this. There is a new thread API instead. */ 
     
    191186    unsigned         i_refcount; 
    192187    vlc_destructor_t pf_destructor; 
    193 #ifndef LIBVLC_REFCHECK 
    194     vlc_thread_t     creator_id; 
    195 #endif 
    196188 
    197189    /* Objects tree structure */ 
  • src/misc/objects.c

    r1cc0014 r5bd06c4  
    8484static void vlc_object_destroy( vlc_object_t *p_this ); 
    8585static void vlc_object_detach_unlocked (vlc_object_t *p_this); 
    86  
    87 #ifdef LIBVLC_REFCHECK 
    88 static vlc_threadvar_t held_objects; 
    89 typedef struct held_list_t 
    90 { 
    91     struct held_list_t *next; 
    92     vlc_object_t *obj; 
    93 } held_list_t; 
    94 static void held_objects_destroy (void *); 
    95 #endif 
    9686 
    9787/***************************************************************************** 
     
    163153        p_priv->next = p_priv->prev = p_new; 
    164154        vlc_mutex_init( &structure_lock ); 
    165 #ifdef LIBVLC_REFCHECK 
    166         /* TODO: use the destruction callback to track ref leaks */ 
    167         vlc_threadvar_create( &held_objects, held_objects_destroy ); 
    168 #endif 
    169155    } 
    170156    else 
     
    195181 
    196182    p_priv->next = VLC_OBJECT (p_libvlc_global); 
    197 #if !defined (LIBVLC_REFCHECK) 
    198     /* ... */ 
    199 #elif defined (LIBVLC_USE_PTHREAD) 
    200     p_priv->creator_id = pthread_self (); 
    201 #elif defined (WIN32) 
    202     p_priv->creator_id = GetCurrentThreadId (); 
    203 #endif 
    204183    vlc_mutex_lock( &structure_lock ); 
    205184    p_priv->prev = vlc_internals (p_libvlc_global)->prev; 
     
    367346        /* We are the global object ... no need to lock. */ 
    368347        vlc_mutex_destroy( &structure_lock ); 
    369 #ifdef LIBVLC_REFCHECK 
    370         held_objects_destroy( vlc_threadvar_get( &held_objects ) ); 
    371         vlc_threadvar_delete( &held_objects ); 
    372 #endif 
    373348    } 
    374349 
     
    758733    internals->i_refcount++; 
    759734    vlc_spin_unlock( &internals->ref_spin ); 
    760 #ifdef LIBVLC_REFCHECK 
    761     /* Update the list of referenced objects */ 
    762     /* Using TLS, so no need to lock */ 
    763     /* The following line may leak memory if a thread leaks objects. */ 
    764     held_list_t *newhead = malloc (sizeof (*newhead)); 
    765     held_list_t *oldhead = vlc_threadvar_get (&held_objects); 
    766     newhead->next = oldhead; 
    767     newhead->obj = p_this; 
    768     vlc_threadvar_set (&held_objects, newhead); 
    769 #endif 
    770735} 
    771736 
     
    778743    vlc_object_internals_t *internals = vlc_internals( p_this ); 
    779744    bool b_should_destroy; 
    780  
    781 #ifdef LIBVLC_REFCHECK 
    782     /* Update the list of referenced objects */ 
    783     /* Using TLS, so no need to lock */ 
    784     for (held_list_t *hlcur = vlc_threadvar_get (&held_objects), 
    785                      *hlprev = NULL; 
    786          hlcur != NULL; 
    787          hlprev = hlcur, hlcur = hlcur->next) 
    788     { 
    789         if (hlcur->obj == p_this) 
    790         { 
    791             if (hlprev == NULL) 
    792                 vlc_threadvar_set (&held_objects, hlcur->next); 
    793             else 
    794                 hlprev->next = hlcur->next; 
    795             free (hlcur); 
    796             break; 
    797         } 
    798     } 
    799     /* TODO: what if releasing without references? */ 
    800 #endif 
    801745 
    802746    vlc_spin_lock( &internals->ref_spin ); 
     
    14891433    } 
    14901434} 
    1491  
    1492 #ifdef LIBVLC_REFCHECK 
    1493 # if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) 
    1494 #  include <execinfo.h> 
    1495 # endif 
    1496  
    1497 void vlc_refcheck (vlc_object_t *obj) 
    1498 { 
    1499     static unsigned errors = 0; 
    1500     if (errors > 100) 
    1501         return; 
    1502  
    1503     /* Anyone can use the root object (though it should not exist) */ 
    1504     if (obj == VLC_OBJECT (vlc_global ())) 
    1505         return; 
    1506  
    1507     /* Anyone can use its libvlc instance object */ 
    1508     if (obj == VLC_OBJECT (obj->p_libvlc)) 
    1509         return; 
    1510  
    1511     /* The thread that created the object holds the initial reference */ 
    1512     vlc_object_internals_t *priv = vlc_internals (obj); 
    1513 #if defined (LIBVLC_USE_PTHREAD) 
    1514     if (pthread_equal (priv->creator_id, pthread_self ())) 
    1515 #elif defined WIN32 
    1516     if (priv->creator_id == GetCurrentThreadId ()) 
    1517 #else 
    1518     if (0) 
    1519 #endif 
    1520         return; 
    1521  
    1522     /* A thread can use its own object without references! */ 
    1523     vlc_object_t *caller = vlc_threadobj (); 
    1524     if (caller == obj) 
    1525         return; 
    1526 #if 0 
    1527     /* The calling thread is younger than the object. 
    1528      * Access could be valid through cross-thread synchronization; 
    1529      * we would need better accounting. */ 
    1530     if (caller && (caller->i_object_id > obj->i_object_id)) 
    1531         return; 
    1532 #endif 
    1533     int refs; 
    1534     vlc_spin_lock (&priv->ref_spin); 
    1535     refs = priv->i_refcount; 
    1536     vlc_spin_unlock (&priv->ref_spin); 
    1537  
    1538     for (held_list_t *hlcur = vlc_threadvar_get (&held_objects); 
    1539          hlcur != NULL; hlcur = hlcur->next) 
    1540         if (hlcur->obj == obj) 
    1541             return; 
    1542  
    1543     int canc = vlc_savecancel (); 
    1544  
    1545     fprintf (stderr, "The %s %s thread object is accessing...\n" 
    1546              "the %s %s object without references.\n", 
    1547              caller && caller->psz_object_name 
    1548                      ? caller->psz_object_name : "unnamed", 
    1549              caller ? caller->psz_object_type : "main", 
    1550              obj->psz_object_name ? obj->psz_object_name : "unnamed", 
    1551              obj->psz_object_type); 
    1552     fflush (stderr); 
    1553  
    1554 #ifdef HAVE_BACKTRACE 
    1555     void *stack[20]; 
    1556     int stackdepth = backtrace (stack, sizeof (stack) / sizeof (stack[0])); 
    1557     backtrace_symbols_fd (stack, stackdepth, 2); 
    1558 #endif 
    1559  
    1560     if (++errors == 100) 
    1561         fprintf (stderr, "Too many reference errors!\n"); 
    1562     vlc_restorecancel (canc); 
    1563 } 
    1564  
    1565 static void held_objects_destroy (void *data) 
    1566 { 
    1567     VLC_UNUSED( data ); 
    1568     held_list_t *hl = vlc_threadvar_get (&held_objects); 
    1569     vlc_object_t *caller = vlc_threadobj (); 
    1570  
    1571     int canc = vlc_savecancel (); 
    1572  
    1573     while (hl != NULL) 
    1574     { 
    1575         held_list_t *buf = hl->next; 
    1576         vlc_object_t *obj = hl->obj; 
    1577  
    1578         fprintf (stderr, "The %s %s thread object leaked a reference to...\n" 
    1579                          "the %s %s object.\n", 
    1580                  caller && caller->psz_object_name 
    1581                      ? caller->psz_object_name : "unnamed", 
    1582                  caller ? caller->psz_object_type : "main", 
    1583                  obj->psz_object_name ? obj->psz_object_name : "unnamed", 
    1584                  obj->psz_object_type); 
    1585         free (hl); 
    1586         hl = buf; 
    1587     } 
    1588     vlc_restorecancel (canc); 
    1589 } 
    1590 #endif 
  • src/misc/variables.c

    r6cd4550 r5bd06c4  
    169169    vlc_object_internals_t *p_priv = vlc_internals( p_this ); 
    170170 
    171     vlc_refcheck( p_this ); 
    172171    vlc_mutex_lock( &p_priv->var_lock ); 
    173172 
     
    333332    vlc_object_internals_t *p_priv = vlc_internals( p_this ); 
    334333 
    335     vlc_refcheck( p_this ); 
    336334    vlc_mutex_lock( &p_priv->var_lock ); 
    337335 
     
    410408    vlc_object_internals_t *p_priv = vlc_internals( p_this ); 
    411409 
    412     vlc_refcheck( p_this ); 
    413410    vlc_mutex_lock( &p_priv->var_lock ); 
    414411 
     
    751748    vlc_object_internals_t *p_priv = vlc_internals( p_this ); 
    752749 
    753     vlc_refcheck( p_this ); 
    754750    vlc_mutex_lock( &p_priv->var_lock ); 
    755751 
     
    829825    vlc_object_internals_t *p_priv = vlc_internals( p_this ); 
    830826 
    831     vlc_refcheck( p_this ); 
    832827    vlc_mutex_lock( &p_priv->var_lock ); 
    833828 
     
    896891    vlc_object_internals_t *p_priv = vlc_internals( p_this ); 
    897892 
    898     vlc_refcheck( p_this ); 
    899893    entry.pf_callback = pf_callback; 
    900894    entry.p_data = p_data; 
     
    934928    vlc_object_internals_t *p_priv = vlc_internals( p_this ); 
    935929 
    936     vlc_refcheck( p_this ); 
    937930    vlc_mutex_lock( &p_priv->var_lock ); 
    938931 
     
    15711564    } 
    15721565 
    1573     vlc_refcheck( p_this ); 
    15741566    i_type = var_Type( p_obj, psz_cmd ); 
    15751567    if( !( i_type&VLC_VAR_ISCOMMAND ) )