[Libav-user] malloc: *** error for object 0x7fda5f816200: pointer being freed was not allocated error in libavformat's av_interleaved_write_frame() while muxing to a webm file

ravikiran.bs ravikiran.bs at zohocorp.com
Tue Jan 2 14:19:50 EET 2018





Hello,



I am trying to mux audio and video streams to a webm file using libavformat. For video stream, when I call av_interleaved_write_frame(), write_packet()

is called, which calls mkv_write_flush_packet()  in matroskaenc.c. 



In that method, av_packet_unref(&MatroskaMuxContext.cur_audio_pkt) is called. MatroskaMuxContext.cur_audio_pkt is basically a cached audio packet. If we have a cached audio packet we are writing it with mkv_write_packet_internal(). And after that we are calling av_packet_unref() to free that packet. But, in that method it is throwing the following error for AVPacket->AVBufferRef->AVBuffer->data, when it is freed.



"malloc: *** error for object 0x7fda5f816200: pointer being freed was not allocated"



I am not freeing any modules prior to this. I have debugged it so far using lldb tool to analyze core dump. I am unable to find the exact cause for this. Am I missing something uninitialized or am I passing some argument wrong? Please help me out. 



P.S:



I am attaching my three C source files here. In that, test.c contains 4 methods, 



initLibrary() - to initialize library

writeVideo()

writeAudio()

closeFile()



which i call accordingly to write audio and video frames to the webm file. And these methods call methods from writewebm.c file.

writewebm.c contains actual FFMpeg library calls. So, this error occurs when I call writeVideo() with AVPacket containing a video frame. But it is not consistent though. 

And, the same issue also occurs when in order to close the file I call av_write_trailer(), where it checks for all cached audio packets and tries to write them to the file.






Thanks.

Ravi Kiran B S









-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20180102/b46bccd5/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.c
Type: application/octet-stream
Size: 1223 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20180102/b46bccd5/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: writewebm.c
Type: application/octet-stream
Size: 9518 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20180102/b46bccd5/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: writewebm.h
Type: application/octet-stream
Size: 1056 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20180102/b46bccd5/attachment-0002.obj>


More information about the Libav-user mailing list