<p>On Jun 27, 2013 10:51 PM, "Paul B Mahol" <<a href="mailto:onemda@gmail.com">onemda@gmail.com</a>> wrote:<br>
><br>
> On 6/27/13, Arvind Raman <<a href="mailto:arvind_raman@yahoo.com">arvind_raman@yahoo.com</a>> wrote:<br>
> > I am developing an application using the FFmpeg libraries and am facing a<br>
> > crash issue that I am finding extremely hard to debug. My printf logs<br>
> > suggest that crash happens within the avcodec_encode_video2() function but I<br>
> > am not sure what is causing the crash.<br>
> ><br>
> > Just for debugging purpose, I created the following infinite loop on the<br>
> > "encode" thread. The loop iterates several times and crashes somewhere in<br>
> > between the 350th and the 400th iteration. The crash is not deterministic.<br>
> > Please note there are video decode (libavcodec) and demux (libavformat)<br>
> > threads running in parallel that are interrupting the<br>
> > avcodec_encode_video2() function. Could this be a problem.<br>
> ><br>
> > Do you spot anything that might be causing the crash? I am using the x.264<br>
> > encoder. The only error log that I get on the terminal is "Segmentation<br>
> > fault (core dumped)" so I am finding it hard to proceed. Is there anyway to<br>
> > get x.264 to print where the crash might be happening.<br>
> ><br>
> > Its quite likely that this might be a silly coding mistake from my end, but<br>
> > just wanted to get a quick check done from you all and receive your<br>
> > suggestions.<br>
> ><br>
> > while(1)<br>
> > {<br>
> > av_init_packet(&encode_packet);<br>
> > frame->pts += 3750;<br>
> ><br>
> > frame->data[0] = frame_buf;<br>
> > frame->data[1] = frame->data[0] + (frame->linesize[0] *<br>
> > encoder_ctx->height);<br>
> > frame->data[2] = frame->data[1] + (frame->linesize[1] *<br>
> > (encoder_ctx->height / 2));<br>
><br>
> This looks wrong, use memcpy instead.<br>
><br>
> > encode_status = avcodec_encode_video2(encoder_ctx, &encode_packet,<br>
> > frame, &got_packet);<br>
> ><br>
> > av_free_packet(&encode_packet);<br>
> > }<br>
> ><br>
> > I tried running valgrind as well but that didn't throw any illegal memory<br>
> > access and it throws the following error. Could this be causing the crash?<br>
> > What is this error about? I saw similar error messages elsewhere as well,<br>
> > but don't think I found any solution there.<br>
> ><br>
> ><br>
> > vex amd64->IR: unhandled instruction bytes: 0x66 0xF 0x38 0x41 0xC0 0x66 0xF<br>
> > 0x7E<br>
> > ==10933== valgrind: Unrecognised instruction at address 0x51393bc.<br>
> > ==10933== at 0x51393BC: ??? (in /usr/local/lib/libx264.so.133)<br>
> > ==10933== by 0x2000200020001F: ???<br>
> > ==10933== Your program just tried to execute an instruction that Valgrind<br>
> > ==10933== did not recognise. There are two possible reasons for this.<br>
> > ==10933== 1. Your program has a bug and erroneously jumped to a non-code<br>
> > ==10933== location. If you are running Memcheck and you just saw a<br>
> > ==10933== warning about a bad jump, it's probably your program's fault.<br>
> > ==10933== 2. The instruction is legitimate but Valgrind doesn't handle it,<br>
> > ==10933== i.e. it's Valgrind's fault. If you think this is the case or<br>
> > ==10933== you are not sure, please let us know and we'll try to fix it.<br>
> > ==10933== Either way, Valgrind will now raise a SIGILL signal which will<br>
> > ==10933== probably kill your program.<br>
> > ==10933==<br>
> > ==10933== Process terminating with default action of signal 4 (SIGILL)<br>
> > ==10933== Illegal opcode at address 0x51393BC<br>
> > ==10933== at 0x51393BC: ??? (in /usr/local/lib/libx264.so.133)<br>
> > ==10933== by 0x2000200020001F: ???<br>
> ><br>
> > Any help would be greatly appreciated!!!<br>
> ><br>
> > Best regards<br>
> > Arvind</p>
<p>Or even easier, there exists avpicture_fill((AVPicture *) frame, frame_buf, encoder_ctx->pix_fmt, frame->width, frame->height);</p>
<p>BR,<br>
Alex Cohn<br>
</p>