unaligned memory read with mplayer's mcdeint filter
Hi, it turns out, for quite some time mplayer has been crashing with a segfault if run with -vf mcdeint=2. There is a message in mplayer-user regarding this. The reason is unaligned memory access in sad16_sse2 function, the first psadbw instruction. It seems that sad16_sse2 expects 16 bytes aligned blk1 and blk2. At the same time, get_block_rd() from snow.c calls it with only 4 bytes aligned data when block_w==8. $ gcc -v Using built-in specs. Target: i486-linux-gnu Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --enable-targets=all --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu Thread model: posix gcc version 4.2.3 20071023 (prerelease) (Ubuntu 4.2.2-3ubuntu3) Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1230223152 (LWP 23204)] 0x085180a9 in sad16_sse2 (v=0xb57843c0, blk2=0xb530bfac '\200' <repeats 200 times>..., blk1=0x8df6a8c '\200' <repeats 200 times>..., stride=672, h=16) at i386/motion_est_mmx.c:94 94 asm volatile( (gdb) bt #0 0x085180a9 in sad16_sse2 (v=0xb57843c0, blk2=0xb530bfac '\200' <repeats 200 times>..., blk1=0x8df6a8c '\200' <repeats 200 times>..., stride=672, h=16) at i386/motion_est_mmx.c:94 #1 0x0848a07c in get_block_rd (s=0xb5578020, mb_x=0, mb_y=0, plane_index=0, obmc_edged=0xbfa68930 "") at snow.c:2867 #2 0x0848ce8a in iterative_me (s=0xb5578020) at snow.c:2974 #3 0x0848fec0 in encode_blocks (s=0xb5578020, search=1) at snow.c:2078 #4 0x084901f1 in encode_frame (avctx=0x8b32100, buf=0xb501b008 "w??\236\tl??HDL\233?\022?\017o?-\217i??\024?\221)?c?\217i??\024?\016\215?Xf_c?", buf_size=3072000, data=0x8baa270) at snow.c:4274 #5 0x082e18da in avcodec_encode_video (avctx=0x8b32100, buf=0xb501b008 "w??\236\tl??HDL\233?\022?\017o?-\217i??\024?\221)?c?\217i??\024?\016\215?Xf_c?", buf_size=3072000, pict=0x8baa270) at utils.c:914 #6 0x0814dfc9 in put_image (vf=0x89418e8, mpi=0x8d51688, pts=0.041999999433755875) at vf_mcdeint.c:103 #7 0x0811bb69 in filter_video (sh_video=0x8939ff0, frame=0x8d51688, pts=0.041999999433755875) at dec_video.c:416 #8 0x080a66bf in main (argc=6, argv=0xbfa6c8f4) at mplayer.c:1745 (gdb) disassemble Dump of assembler code for function sad16_sse2: 0x08518080 <sad16_sse2+0>: push %ebp 0x08518081 <sad16_sse2+1>: mov %esp,%ebp 0x08518083 <sad16_sse2+3>: mov 0x10(%ebp),%ecx 0x08518086 <sad16_sse2+6>: push %ebx 0x08518087 <sad16_sse2+7>: mov 0x14(%ebp),%edx 0x0851808a <sad16_sse2+10>: mov 0xc(%ebp),%ebx 0x0851808d <sad16_sse2+13>: mov 0x18(%ebp),%eax 0x08518090 <sad16_sse2+16>: pxor %xmm6,%xmm6 0x08518094 <sad16_sse2+20>: lea 0x0(%esi),%esi 0x0851809a <sad16_sse2+26>: lea 0x0(%edi),%edi 0x085180a0 <sad16_sse2+32>: movdqu (%ecx),%xmm0 0x085180a4 <sad16_sse2+36>: movdqu (%ecx,%edx,1),%xmm1 0x085180a9 <sad16_sse2+41>: psadbw (%ebx),%xmm0 0x085180ad <sad16_sse2+45>: psadbw (%ebx,%edx,1),%xmm1 0x085180b2 <sad16_sse2+50>: paddw %xmm0,%xmm6 0x085180b6 <sad16_sse2+54>: paddw %xmm1,%xmm6 0x085180ba <sad16_sse2+58>: lea (%ecx,%edx,2),%ecx 0x085180bd <sad16_sse2+61>: lea (%ebx,%edx,2),%ebx 0x085180c0 <sad16_sse2+64>: sub $0x2,%eax 0x085180c3 <sad16_sse2+67>: jg 0x85180a0 <sad16_sse2+32> 0x085180c5 <sad16_sse2+69>: movhlps %xmm6,%xmm0 0x085180c8 <sad16_sse2+72>: paddw %xmm0,%xmm6 0x085180cc <sad16_sse2+76>: movd %xmm6,%eax 0x085180d0 <sad16_sse2+80>: pop %ebx 0x085180d1 <sad16_sse2+81>: pop %ebp 0x085180d2 <sad16_sse2+82>: ret End of assembler dump. (gdb) info all-registers eax 0x10 16 ecx 0x8df6a8c 148859532 edx 0x2a0 672 ebx 0xb530bfac -1255096404 esp 0xbfa5cd54 0xbfa5cd54 ebp 0xbfa5cd58 0xbfa5cd58 esi 0xb5578020 -1252556768 edi 0x8df7510 148862224 eip 0x85180a9 0x85180a9 <sad16_sse2+41> eflags 0x210286 [ PF SF IF RF ID ] cs 0x73 115 ss 0x7b 123 ds 0x7b 123 es 0x7b 123 fs 0x0 0 gs 0x33 51 st0 -nan(0x080808080) (raw 0xffff0000000080808080) st1 -nan(0x080808080) (raw 0xffff0000000080808080) st2 <invalid float value> (raw 0xffff0000000000000000) st3 <invalid float value> (raw 0xffff0000000000000000) st4 <invalid float value> (raw 0xffff0000000000000000) st5 -nan(0x1111111111111111) (raw 0xffff1111111111111111) st6 -nan(0x1111111111111111) (raw 0xffff1111111111111111) st7 <invalid float value> (raw 0xffff0000000000000000) fctrl 0x37f 895 fstat 0x20 32 ftag 0xaaaa 43690 fiseg 0x73 115 fioff 0x847e61b 138929691 foseg 0x7b 123 fooff 0xbfa69ffc -1079599108 fop 0x34d 845 xmm0 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x80 <repeats 16 times>}, v8_int16 = { 0x8080, 0x8080, 0x8080, 0x8080, 0x8080, 0x8080, 0x8080, 0x8080}, v4_int32 = {0x80808080, 0x80808080, 0x80808080, 0x80808080}, v2_int64 = {0x8080808080808080, 0x8080808080808080}, uint128 = 0x80808080808080808080808080808080} xmm1 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x80 <repeats 16 times>}, v8_int16 = { 0x8080, 0x8080, 0x8080, 0x8080, 0x8080, 0x8080, 0x8080, 0x8080}, v4_int32 = {0x80808080, 0x80808080, 0x80808080, 0x80808080}, v2_int64 = {0x8080808080808080, 0x8080808080808080}, uint128 = 0x80808080808080808080808080808080} xmm2 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x12 <repeats 12 times>, 0x11, 0x11, 0x11, 0x11}, v8_int16 = {0x1212, 0x1212, 0x1212, 0x1212, 0x1212, 0x1212, 0x1111, 0x1111}, v4_int32 = {0x12121212, 0x12121212, 0x12121212, 0x11111111}, v2_int64 = {0x1212121212121212, 0x1111111112121212}, uint128 = 0x11111111121212121212121212121212} xmm3 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x12 <repeats 12 times>, 0x11, 0x11, 0x11, 0x11}, v8_int16 = {0x1212, 0x1212, 0x1212, 0x1212, 0x1212, 0x1212, 0x1111, 0x1111}, v4_int32 = {0x12121212, 0x12121212, 0x12121212, 0x11111111}, v2_int64 = {0x1212121212121212, 0x1111111112121212}, uint128 = 0x11111111121212121212121212121212} ---Type <return> to continue, or q <return> to quit--- xmm4 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000} xmm5 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x11 <repeats 16 times>}, v8_int16 = { 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111, 0x1111}, v4_int32 = {0x11111111, 0x11111111, 0x11111111, 0x11111111}, v2_int64 = {0x1111111111111111, 0x1111111111111111}, uint128 = 0x11111111111111111111111111111111} xmm6 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000} xmm7 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000} mxcsr 0x1f80 [ IM DM ZM OM UM PM ] mm0 {uint64 = 0x80808080, v2_int32 = {0x80808080, 0x0}, v4_int16 = {0x8080, 0x8080, 0x0, 0x0}, v8_int8 = {0x80, 0x80, 0x80, 0x80, 0x0, 0x0, 0x0, 0x0}} mm1 {uint64 = 0x80808080, v2_int32 = {0x80808080, 0x0}, v4_int16 = {0x8080, 0x8080, 0x0, 0x0}, v8_int8 = {0x80, 0x80, 0x80, 0x80, 0x0, 0x0, 0x0, 0x0}} mm2 {uint64 = 0x0, v2_int32 = {0x0, 0x0}, v4_int16 = {0x0, 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}} mm3 {uint64 = 0x0, v2_int32 = {0x0, 0x0}, v4_int16 = {0x0, 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}} mm4 {uint64 = 0x0, v2_int32 = {0x0, 0x0}, v4_int16 = {0x0, 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}} mm5 {uint64 = 0x1111111111111111, v2_int32 = {0x11111111, 0x11111111}, v4_int16 = {0x1111, 0x1111, 0x1111, 0x1111}, v8_int8 = {0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11}} mm6 {uint64 = 0x1111111111111111, v2_int32 = {0x11111111, 0x11111111}, v4_int16 = {0x1111, 0x1111, 0x1111, 0x1111}, v8_int8 = {0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11}} mm7 {uint64 = 0x0, v2_int32 = {0x0, 0x0}, v4_int16 = {0x0, 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
participants (1)
-
eugeni.stepanov@gmail.com