[MPlayer-users] All XVID encoded videos with size 624x352 cause mplayer to segfault (current and previous svn snapshots)

Mike Gorchak mike.gorchak.qnx at gmail.com
Thu Feb 7 14:43:05 CET 2013


> There are functions that require no alignment at all
> (and functions that require alignment higher than
> 16 bytes).

It was very unexpected, but I've found a bug in QNX's memalign() and
posix_memalign() functions. A patch for ffmpeg/libavutil/mem.c is
attached.

As far as I can see ffplay/ffmpeg allocates video buffers with
different strides than mplayer, so that is why ffplay works.

By the way I have found a bug in the av_malloc() function when
CONFIG_MEMALIGN_HACK is used. The code looks like:

#if CONFIG_MEMALIGN_HACK
    ptr = malloc(size + ALIGN);
    if (!ptr)
        return ptr;
    diff              = ((~(long)ptr)&(ALIGN - 1)) + 1;
    ptr               = (char *)ptr + diff;
    ((char *)ptr)[-1] = diff;

After malloc() there is needed a check for ptr which can be ALREADY
aligned. In this case we have not to execute this line: ((char
*)ptr)[-1] = diff; which can cause a memory trashing. But better to
allocate (size+2*ALIGN) bytes and then move ptr forward for ALIGN
bytes to make sure that buffer has spare space for writting a 'diff'
value.

Thanks.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mplayer-qnx-ffmpeg-mem.diff
Type: application/octet-stream
Size: 977 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-users/attachments/20130207/33c44a9b/attachment.obj>


More information about the MPlayer-users mailing list