I'm having some issues trying to clean up the memory allocations from using 
libavformat and libavcodec, but I'm getting seemingly arbitrary segfaults when 
doing so.  In particular, I cannot call avcodec_close, or 
av_close_input_stream, without generating a segfault.

The locations where these segfaults appear to be happening don't make much 
sense to me.  For avcodec_close, it claims to be faulting after this call 
chain:

(I'm using static libav* libraries, linked into a dynamic JNI library, running 
on my Android phone, so the debugging information is limited to running the 
stack trace addresses through addr2line:)

#00  pc 00526724  av_freep /home/kutulu/workspace/ffmpeg/libavutil/mem.c:153
#01  pc 003e6304  avcodec_default_free_buffers 
/home/kutulu/workspace/ffmpeg/libavcodec/utils.c:989
#02  pc 003e6c4c  avcodec_close 
/home/kutulu/workspace/ffmpeg/libavcodec/utils.c:729

According to this, the segfault is happening here:

for(j=0; j<4; j++){
  av_freep(&buf->base[j]);  // <--- here
  buf->data[j]= NULL;
}

If I skip avcodec_close and just call av_close_input_stream, the stack trace 
gives me:

#00  pc 0001066a  /system/lib/libc.so
#01  pc 0000afae  /system/lib/libc.so
#02  pc 00328aa4  av_parser_close 
/home/kutulu/workspace/ffmpeg/libavcodec/parser.c:238
#03  pc 000beafc  av_close_input_stream 
/home/kutulu/workspace/ffmpeg/libavformat/utils.c:2452

which is here (though I have also seen the segfault on the previous line, so 
the addresses might be off a bit):

if (s->parser->parser_close)
    s->parser->parser_close(s);
av_free(s->priv_data); // <--- here
av_free(s);

I can't see why any of these things wouldn't be safe to free; I'm not doing 
anything unusual with the contexts once I have them besides pass them to 
av_read_frame and avcodec_decode_audio3.  

Can anyone point me in the right direction?

--Mike
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to