You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm seeing a crash inside InputContainer::cinit, in the call to av_dict_free if I pass any options to av.open:
==102753== Thread 97:
==102753== Invalid read of size 4
==102753== at 0xAD2253D: av_dict_free (in venv/lib/python3.12/site-packages/av.libs/libavutil-a63ffd27.so.59.39.100)
==102753== by 0x1066D75B: __pyx_pf_2av_9container_5input_14InputContainer___cinit__ (input.c:4121)
==102753== by 0x1066D75B: __pyx_pw_2av_9container_5input_14InputContainer_1__cinit__ (input.c:3769)
==102753== by 0x1066D75B: __pyx_tp_new_2av_9container_5input_InputContainer (input.c:7059)
==102753== by 0x599A76: ??? (in /usr/bin/python3.12)
==102753== by 0x548F54: _PyObject_MakeTpCall (in /usr/bin/python3.12)
==102753== by 0xFF1C5A1: __pyx_pf_2av_9container_4core_open (core.c:9158)
==102753== by 0xFF1C5A1: __pyx_pw_2av_9container_4core_1open (core.c:8752)
==102753== by 0x5DA965: _PyEval_EvalFrameDefault (in /usr/bin/python3.12)
==102753== by 0x66C158: ??? (in /usr/bin/python3.12)
==102753== by 0x65A8D43: ??? (in /usr/lib/python3.12/lib-dynload/_asyncio.cpython-312-x86_64-linux-gnu.so)
==102753== by 0x65A8B5A: ??? (in /usr/lib/python3.12/lib-dynload/_asyncio.cpython-312-x86_64-linux-gnu.so)
==102753== by 0x548F54: _PyObject_MakeTpCall (in /usr/bin/python3.12)
==102753== by 0x6A480B: ??? (in /usr/bin/python3.12)
==102753== by 0x581E9C: ??? (in /usr/bin/python3.12)
==102753== Address 0x730dda74696c7073 is not stack'd, malloc'd or (recently) free'd
avformat_find_stream_info can find additional streams, which leads to av_dict_free(&c_options[i]) being out-of-bounds.
A workaround can be to set options after opening with container.options.update() instead of passing them to av.open. I'm guessing there are options that you want set during av.open, but it's working for me so far.
shows before: 0, after: 1. The problem is pretty straightforward: InputContainer allocates c_options with size 0, calls avformat_find_stream_info which changes nb_streams to 1, then calls av_dict_free() on an array element that doesn't exist.
Activity
zewt commentedon Sep 6, 2025
A workaround can be to set options after opening with container.options.update() instead of passing them to av.open. I'm guessing there are options that you want set during av.open, but it's working for me so far.
WyattBlue commentedon Sep 6, 2025
How can someone reproduce this?
zewt commentedon Sep 6, 2025
Seems like it happens with any MPEG:
It doesn't discover the stream until format_find_stream_info is called, so nb_streams is 0 before and 1 after.
WyattBlue commentedon Sep 6, 2025
hello world
<av.InputContainer 'test.mpg'>
15.1.0
Umm, okay. What's your version and platform?
zewt commentedon Sep 6, 2025
(Umm, okay. If I'm bothering you with a bug report I'll just use the easy workaround.)
15.1.0, Linux. nb_streams is changing:
shows before: 0, after: 1. The problem is pretty straightforward: InputContainer allocates c_options with size 0, calls avformat_find_stream_info which changes nb_streams to 1, then calls av_dict_free() on an array element that doesn't exist.
Fix PyAV-Org#2010