[MPlayer-dev-eng] [CRASH] mpi->planes[0] needs to be aligned at least to 16 byte or put_pixels16_sse2 will crash

Gianluigi Tiesi mplayer at netfarm.it
Wed Mar 17 07:35:45 CET 2010


On Wed, Mar 17, 2010 at 01:46:59PM +0800, Zuxy Meng wrote:
> Hi,
> 
> 2010/3/16 Gianluigi Tiesi <mplayer at netfarm.it>:
> > I've noticed that memalign is an alias for malloc on mingw
> > and mp images allocates planes this way:
> > memalign(64, mpi...)
> >
> > after some functions in libavcodec:
> >
> >
> > put_pixels16_sse2(uint8_t *block
> >
> > block is not 16bytes aligned
> > and it crashes on p4
> >
> > I think we may need to make custom alloc/dealloc/strdup functions
> > to avoid these problems, mingwex offers:
> >
> > __mingw_aligned_malloc
> > __mingw_aligned_realloc
> > __mingw_aligned_free
> >
> > that can be used for this
> >
> 
> I mentioned this in another thread several days ago. To fix it once
> and for all we'd substitute all call to malloc/memalign and free to
> av_malloc and av_free across mplayer, but I can't think of a graceful
> way to do this in win32. I tried defining my own malloc/memalign and
> free and linking it before libmsvcrt but it didn't work.
> 

I've tried a wrapper for malloc and friends call to handle transparently
but does not look so easy, at some point the calls anyway free() on a ptr
not allocated by my wrapper but I'm unable to find where
maybe in mingw crt init code.

Currently the only way to wrap it (I think) is make the wrapper
use loadlibrary msvcrt and getprocaddr of malloc/realloc/free
or you'll get a loop

parse.c already has a workaround for this problem
mp_image aligns to 64, but 16 is mandatory on system with sse

I see also others memalign >=16 in vf_noise (but looks like no sse code)
in vf_screenshot (but I'm not sure here sse is used)

I think the better way would be use mp_memalign,
that is wrapped (not transparently on mingw)
but find relative free() and wrap also with mp_free()

since it's not always easy to known where use mp_free instead of free
I suggest to wrap all allocations

Regards


-- 
Gianluigi Tiesi <sherpya at netfarm.it>
EDP Project Leader
Netfarm S.r.l. - http://www.netfarm.it/
Free Software: http://oss.netfarm.it/



More information about the MPlayer-dev-eng mailing list