[Ffmpeg-devel] Seg fault
Wed Nov 23 10:56:31 CET 2005
2005/11/21, g. <the_ether at lycos.co.uk>:
> I am getting a segmentation fault in ByteSwap32 of bswap.h
> All I did was exchange the diff_pixels_mmx routine with a new one and now I
> get the segemntation fault in a totally unrelated area. On my test sequence it
> occurs in the 7th frame, so all is okay for over 8,000 thousand blocks.
> It occurs from put_bits being called from mpeg1_encode_block and occurs on
> block number 5 of the macroblock.
> It is either a subtle bug with ByteSwap32 or a compiler / linker problem. I
> changed the optimisation level down to 1 and deleted the frame pointer removal
> option but that didn't fix it. The new pixel_diff routine I am using is being
> linked in from a Windows library but if there was some weird linker error I
> doubt I would have managed to get through 8,000+ blocks before encountering a
> problem that resulted from bad linkage.
> The src of the ffmpeg code I crash in is:
> static inline uint32_t ByteSwap32(uint32_t x)
> #if __CPU__ > 386
> __asm("bswap %0":
> "=r" (x) :
> __asm("xchgb %b0,%h0\n"
> " rorl $16,%0\n"
> " xchgb %b0,%h0":
> LEGACY_REGS (x) :
> "0" (x));
> return x;
> I am using a P4 HT and gcc version 3.4.2 under MinGW.
If I understand you right you haven't changed the ByteSwap32 function,
so it is pointless to paste it.
Even more, as you use cpu >386, you have one operand that is register
and it is impossible for it to segfault (it doesn't access memory, it
doesn't compute segment arithmetic).
What you should do is look for bug in your new diff_pixels_mmx routine.
Compleatly removing optimizations, inline-ing, increasing debug level
or even using another debuger may help you find YOUR bug.
More information about the ffmpeg-devel