#7094(avformat:new): Assertion in AVIO fill_buffer
#7094: Assertion in AVIO fill_buffer -------------------------------------+------------------------------------- Reporter: redeemarr | Type: defect Status: new | Priority: normal Component: avformat | Version: git- Keywords: avio, | master abort, crash | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+------------------------------------- It happens sometimes while demuxing mpegts stream using custom IO operations via AVIOContext, assertion fails in function 'fill_buffer' in aviobuf.c: av_assert0(len >= s->orig_buffer_size); Seems like something goes wrong when AVIOContext decides to reduce it's internal buffer size. This issue can be easily reproduced in my case, when AVFormatContext.probesize equals initial buffer size for AVIOContext. Sample code to reproduce: {{{#!c++ int read_handler(void* opaque, uint8_t* dst, int dst_size) { bytes_t* input = (bytes_t*)opaque; size_t available = input->size(); size_t size = available < dst_size ? available : dst_size; if (size > 0) { memcpy(dst, input->data(), size); input->erase(input->begin(), input->begin() + size); } return size > 0 ? size : AVERROR_EOF; } void test_avio(char const* path) { std::ifstream ifs(path, std::ios::binary); ifs.seekg(0, std::ios::end); size_t size = ifs.tellg(); ifs.seekg(0, std::ios::beg); std::vector<char> input(size); ifs.read(input.data(), input.size()); AVInputFormat* m_format = av_find_input_format("mpegts"); AVFormatContext* m_fc = avformat_alloc_context(); size_t buffer_size = 16 * 1024; uint8_t* avio_buffer = (uint8_t*)av_malloc(buffer_size + FF_INPUT_BUFFER_PADDING_SIZE); m_fc = avformat_alloc_context(); m_fc->probesize = buffer_size; m_fc->pb = avio_alloc_context(avio_buffer, buffer_size, 0, &input, &read_handler, NULL, NULL); m_fc->pb->seekable = 0; m_fc->pb->write_flag = 0; int err = avformat_open_input(&m_fc, NULL, m_format, NULL); err = avformat_find_stream_info(m_fc, NULL); // In this case it fails even at this point // ... } }}} -- Ticket URL: <https://trac.ffmpeg.org/ticket/7094> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#7094: Assertion in AVIO fill_buffer -------------------------------------+------------------------------------- Reporter: redeemarr | Owner: Type: defect | Status: new Priority: normal | Component: avformat Version: git-master | Resolution: Keywords: avio, | Blocked By: abort, crash | Reproduced by developer: 0 Blocking: | Analyzed by developer: 0 | -------------------------------------+------------------------------------- Comment (by redeemarr): Unfortunately I could not attach sample TS file since it's size is beyond 2.5MB -- Ticket URL: <https://trac.ffmpeg.org/ticket/7094#comment:1> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#7094: Assertion in AVIO fill_buffer -------------------------------------+------------------------------------- Reporter: redeemarr | Owner: Type: defect | Status: new Priority: normal | Component: avformat Version: git-master | Resolution: Keywords: avio, | Blocked By: abort, crash | Reproduced by developer: 0 Blocking: | Analyzed by developer: 0 | -------------------------------------+------------------------------------- Comment (by cehoyos): Please use a file hoster of your choice and post a download link here. -- Ticket URL: <https://trac.ffmpeg.org/ticket/7094#comment:2> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#7094: Assertion in AVIO fill_buffer -------------------------------------+------------------------------------- Reporter: redeemarr | Owner: Type: defect | Status: new Priority: normal | Component: avformat Version: git-master | Resolution: Keywords: avio, | Blocked By: abort, crash | Reproduced by developer: 0 Blocking: | Analyzed by developer: 0 | -------------------------------------+------------------------------------- Comment (by redeemarr): Original TS file had been lost, so here's new one - http://rgho.st/8rmvywQ6s It requires buffer_size = 64*4096 to reproduce -- Ticket URL: <https://trac.ffmpeg.org/ticket/7094#comment:3> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#7094: Assertion in AVIO fill_buffer -------------------------------------+------------------------------------- Reporter: redeemarr | Owner: Type: defect | Status: new Priority: normal | Component: avformat Version: git-master | Resolution: Keywords: avio, | Blocked By: abort, crash | Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+------------------------------------- Changes (by michael): * cc: michael (added) Comment: Can you check if "[FFmpeg-devel] [PATCH] avformat/aviobuf: Delay buffer downsizing until asserts are met" on the mailing list fixes this or provide a simple testcase like a compilable file or something that doesnt require writing a testcase based of code snippets thanks -- Ticket URL: <https://trac.ffmpeg.org/ticket/7094#comment:4> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#7094: Assertion in AVIO fill_buffer -------------------------------------+------------------------------------- Reporter: redeemarr | Owner: Type: defect | Status: closed Priority: normal | Component: avformat Version: git-master | Resolution: fixed Keywords: avio, | Blocked By: abort, crash | Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+------------------------------------- Changes (by mkver): * status: new => closed * resolution: => fixed Comment: The patch that Michael invited you to test got merged and removed said assertion, so that it's certain that you won't run into it any more. Therefore I am closing this issue as fixed. Should everything work fine for you with this fix, then please confirm it here; if not, open a new ticket for it. -- Ticket URL: <https://trac.ffmpeg.org/ticket/7094#comment:5> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
participants (1)
-
FFmpeg