[FFmpeg-devel] [PATCH] pthread_frame: do not attempt to unlock a mutex on the wrong thread
wm4
nfxjfg at googlemail.com
Sat Mar 25 13:01:00 EET 2017
On Fri, 24 Mar 2017 18:53:41 +0100
Michael Niedermayer <michael at niedermayer.cc> wrote:
> On Fri, Mar 24, 2017 at 01:47:10PM +0100, wm4 wrote:
> > async_mutex has is used in a very strange but intentional way: it is
> > locked by default, and unlocked only in regions that can be run
> > concurrently.
> >
> > If the user was calling API functions to the same context from different
> > threads (in a safe way), this could unintentionally unlock the mutex on
> > a different thread than the previous lock operation. It's not allowed by
> > the pthread API.
> >
> > Fix this by emulating a binary semaphore using a mutex and condition
> > variable. (Posix semaphores are not available on all platforms.)
> > ---
> > libavcodec/pthread_frame.c | 41 +++++++++++++++++++++++++++++++----------
> > 1 file changed, 31 insertions(+), 10 deletions(-)
>
> this breaks flac
>
> make -j12 ffmpeg && ./ffmpeg -i ~/tickets/4421/testwav_cut.wav out.flac ; ./ffmpeg -i out.flac -f null -
> https://trac.ffmpeg.org/attachment/ticket/4421/testwav_cut.wav
>
> Input #0, flac, from 'out.flac':
> Metadata:
> ENCODER : Lavf57.67.100
> Duration: 00:00:10.00, start: 0.000000, bitrate: 912 kb/s
> Stream #0:0: Audio: flac, 44100 Hz, stereo, s16
> Stream mapping:
> Stream #0:0 -> #0:0 (flac (native) -> pcm_s16le (native))
> Press [q] to stop, [?] for help
> Output #0, null, to 'pipe:':
> Metadata:
> encoder : Lavf57.67.100
> Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
> Metadata:
> encoder : Lavc57.86.103 pcm_s16le
> Assertion ret <= avpkt->size failed at libavcodec/utils.c:2507
> Aborted
>
> [...]
I get:
testwav_cut.wav: Invalid data found when processing input
Can't reproduce.
More information about the ffmpeg-devel
mailing list