[FFmpeg-devel] [PATCH] Force users to specify memalign_hack in configure
Ramiro Polla
ramiro
Tue May 6 07:43:46 CEST 2008
Hello,
>> And please give us more information about this crash. You have not yet
>> provided any gdb output as to where and how it crashes. Also I couldn't
>> find any docs on the Internet about this DOS fragility.
>
> (gdb) r
> Starting program: d:/src/ffmpeg-export-2008-05-06/ffmpeg_g.exe
>
> Program received signal SIGSEGV, Segmentation fault.
> sws_getContext (srcW=16, srcH=16, srcFormat=0, dstW=16, dstH=16, dstFormat=0,
> flags=4, srcFilter=0x0, dstFilter=0x0, param=0x0)
> at libavcodec/imgresample.c:539
> 539 ctx->resampling_ctx->iheight = srcH;
> (gdb) bt
> #0 sws_getContext (srcW=16, srcH=16, srcFormat=0, dstW=16, dstH=16,
> dstFormat=0, flags=4, srcFilter=0x0, dstFilter=0x0, param=0x0)
> at libavcodec/imgresample.c:539
> #1 0x00009369 in main (argc=) at ffmpeg.c:3914
> (gdb) disas $pc-32 $pc+32
> Dump of assembler code from 0x9a1f6 to 0x9a236:
> 0x0009a1f6 <sws_getContext+138>: call 0x3cd578 <av_log>
> 0x0009a1fb <sws_getContext+143>: add $0x10,%esp
> 0x0009a1fe <sws_getContext+146>: jmp 0x9a1ad <sws_getContext+65>
> 0x0009a200 <sws_getContext+148>: cmp 0x2c(%esp),%ebp
> 0x0009a204 <sws_getContext+152>: jne 0x9a19d <sws_getContext+49>
> 0x0009a206 <sws_getContext+154>: sub $0xc,%esp
> 0x0009a209 <sws_getContext+157>: push $0x148
> 0x0009a20e <sws_getContext+162>: call 0x3cd3cc <av_malloc>
> 0x0009a213 <sws_getContext+167>: mov %eax,0x4(%ebx)
> 0x0009a216 <sws_getContext+170>: mov %esi,0x4(%eax)
> 0x0009a219 <sws_getContext+173>: mov %ebp,(%eax)
> 0x0009a21b <sws_getContext+175>: mov %esi,0xc(%eax)
> 0x0009a21e <sws_getContext+178>: mov %ebp,0x8(%eax)
> 0x0009a221 <sws_getContext+181>: add $0x10,%esp
> 0x0009a224 <sws_getContext+184>: jmp 0x9a1d2 <sws_getContext+102>
> 0x0009a226 <sws_getContext+186>: push %eax
> 0x0009a227 <sws_getContext+187>: push $0x9a0fc
> 0x0009a22c <sws_getContext+192>: push $0x0
> 0x0009a22e <sws_getContext+194>: push $0x0
> 0x0009a230 <sws_getContext+196>: call 0x3cd578 <av_log>
> 0x0009a235 <sws_getContext+201>: xor %edi,%edi
> End of assembler dump.
> (gdb) info all-registers
> eax 0x0 0
> ecx 0x10 16
> edx 0x288 648
> ebx 0x58e050 5824592
> esp 0x58cc50 0x58cc50
> ebp 0x10 0x10
> esi 0x10 16
> edi 0x58e050 5824592
> eip 0x9a216 0x9a216 <sws_getContext+170>
> eflags 0x13002 77826
> cs 0x12f 303
> ss 0x137 311
> ds 0x137 311
> es 0x137 311
> fs 0x127 295
> gs 0x147 327
av_malloc() returned NULL as you can see in eax. So I went to check why
would malloc() return a valid value from inside CONFIG_MEMALIGN_HACK but
not when called directly. Then I found out DJGPP has memalign(), so
malloc() wasn't being called when it crashed. And then I came across
[1]. It says it's not POSIX nor ANSI compatible, so I went to check the
POSIX definition of memalign(), and found out memalign() is not even
POSIX. I found one definition in [2], though.
The size and alignment parameters are switched between what FFmpeg
expects and the DJGPP implementation. So, in fact, you should force
memalign() to be disabled in DJGPP, and not for memalign_hack to be enabled.
Ramiro Polla
[1] http://www.delorie.com/djgpp/doc/libc/libc_562.html
[2] http://linux.die.net/man/3/memalign
More information about the ffmpeg-devel
mailing list