[Ffmpeg-devel] segfault during avcodec_close()

Måns Rullgård mru
Tue Oct 24 04:06:02 CEST 2006


Matthew Hodgson <matthew at mxtelecom.com> writes:

> Hi all,
>
> I'm experiencing a segfault when running avcodec_close() in one thread
> whilst avcodec_decode_video() is running in another.  Should
> avcodec_close() be threadsafe, or do I need to grab a lock to ensure
> the two don't collide?
>
> Valgrind spews a lot of the following before dying:
>
> ==29697== Invalid read of size 1
> ==29697==    at 0x81449C2: guess_mv (error_resilience.c:501)
> ==29697==    by 0x8142747: ff_er_frame_end (error_resilience.c:905)
> ==29697==    by 0x8186412: ff_h263_decode_frame_end (h263dec.c:639)
> ==29697==    by 0x8184E9A: ff_h263_decode_frame (h263dec.c:815)
> ==29697==    by 0x8098A51: avcodec_decode_video (utils.c:376)
> ...
> ==29697==  Address 0x60D6C4F is 5,375 bytes inside a block of size
> 54,928 free'd
> ==29697==    at 0x401A13C: free (vg_replace_malloc.c:235)
> ==29697==    by 0x8098C11: avcodec_default_free_buffers (utils.c:106)
> ==29697==    by 0x8099FC0: MPV_common_end (mpegvideo.c:552)
> ==29697==    by 0x81852E3: ff_h263_decode_end (h263dec.c:132)
> ==29697==    by 0x8098AE5: avcodec_close (utils.c:405)
> ==29697==    by 0x8082F78: teardown_ffmpeg (rtp.c:1441)

It should be safe to call those functions concurrently with different
contexts.  You obviously can't call those functions with the same
context at the same time, which it appears that you've been doing.

-- 
M?ns Rullg?rd
mru at inprovide.com




More information about the ffmpeg-devel mailing list