2nd libvlc_destroy() call is crashing

Microsoft Windows specific usage questions
Forum rules
Please post only Windows specific questions in this forum category. If you don't know where to post, please read the different forums' rules. Thanks.
g6r6e6g
New Cone
New Cone
Posts: 8
Joined: 05 May 2008 16:39

2nd libvlc_destroy() call is crashing

Postby g6r6e6g » 09 Jan 2009 15:04

Hello,

I try to play 2 videos on vlc086e (win32 libvlc) with vmem plugin,
I create new instance/play 1st video => OK
I createnew instance/play 2nd video => OK
I stop and destroy correctly my 1st instance,
but libvlc_destroy() crash on my 2nd instance.
If I create/destroy 2 videos sequentially, no problem !

Any idea ?
Thank you

I m using those args :

Code: Select all

"--no-one-instance", "--loop", "--no-stats", "--intf", "dummy", "--fast-mutex", "--win9x-cv-method=1", "--plugin-path=.\\VLCplugins", "--vout", "vmem", "--vmem-width", pwidth, "--vmem-height", pheight, "--vmem-pitch", ppitch, "--vmem-chroma", "RV16", "--vmem-lock", plock, "--vmem-unlock", punlock, "--vmem-data", pdata,

erwan10
Developer
Developer
Posts: 415
Joined: 02 Nov 2008 23:16

Re: 2nd libvlc_destroy() call is crashing

Postby erwan10 » 09 Jan 2009 15:53

beware of multiple instances of libvlc ! They are not independent.

A new libvlc instance overwrites options passed to a previous one. In the case of vmem, some of these options are pointers to functions So you can very easily end up with a crash.

g6r6e6g
New Cone
New Cone
Posts: 8
Joined: 05 May 2008 16:39

Re: 2nd libvlc_destroy() call is crashing

Postby g6r6e6g » 09 Jan 2009 16:55

Thank you erwan10 for your response,

If I understand there is 1 risk when using config_GetPsz()
but config_GetPsz() is only called in Init() of vmem and args are copied into
instance datas ...
so I do not see the impact on libvlc_destroy().

vmem source code part :

Code: Select all

struct vout_sys_t { int i_width, i_height, i_pitch; void * (*pf_lock) (void *); void (*pf_unlock) (void *); void *p_data; }; static int Create( vlc_object_t *p_this ) { vout_thread_t *p_vout = ( vout_thread_t * )p_this; /* Allocate instance and initialize some members */ p_vout->p_sys = malloc( sizeof( vout_sys_t ) ); . . . static int Init( vout_thread_t *p_vout ) { . . . psz_tmp = config_GetPsz( p_vout, "vmem-lock" ); p_vout->p_sys->pf_lock = (void * (*) (void *))(intptr_t)atoll( psz_tmp ); free( psz_tmp ); . . . static void Destroy( vlc_object_t *p_this ) { vout_thread_t *p_vout = ( vout_thread_t * )p_this; /* Destroy structure */ free( p_vout->p_sys ); }

I tried the same test without using vmem and I found an interesting think :
when I compile/link on cygwin => OK
when I compile/link with VisualStudio2005 => libvlc_destroy() crashes on 2nd call


After some investigations, I found crash in 2nd call to libvlc_destroy() occurs in VLCsources/misc/messages.c

Code: Select all

void __msg_Destroy( vlc_object_t *p_this ) { int i; for( i = p_this->p_libvlc->msg_bank.i_queues -1 ; i >= 0; i-- ) { ... } vlc_mutex_destroy( &(p_this->p_libvlc->msg_bank.lock) ); <= this lock in libvlc context is maybe already freed !! }

g6r6e6g
New Cone
New Cone
Posts: 8
Joined: 05 May 2008 16:39

Re: 2nd libvlc_destroy() call is crashing

Postby g6r6e6g » 12 Jan 2009 11:43

In libvlc.c, we only create the Msg queue on 1st call to VLC_Create(), but when calling VLC_Destroy() we systematically destroy the Msg queue, can someone confirm there is 1 bug here ?

Code: Select all

int VLC_Create( void ) { ... if( !libvlc.b_ready ) { ... /* Initialize message queue */ msg_Create( p_libvlc ); ... libvlc.b_ready = VLC_TRUE; } int VLC_Destroy( int i_object ) { ... /* * System specific cleaning code */ system_End( p_vlc ); /* * Free message queue. * Nobody shall use msg_* afterward. */ msg_Flush( p_vlc ); msg_Destroy( p_libvlc ); ... }
Sorry for this double-post, just want some expert help ;-)
Thank you


Return to “VLC media player for Windows Troubleshooting”

Who is online

Users browsing this forum: No registered users and 24 guests