gst-python issueshttps://gitlab.freedesktop.org/gstreamer/gst-python/-/issues2023-07-13T16:22:25Zhttps://gitlab.freedesktop.org/gstreamer/gst-python/-/issues/22Segfault on bus message callback with missing userdata2023-07-13T16:22:25ZFlorent ThierySegfault on bus message callback with missing userdataWhile trying to test some intervideosrc/sink pipelines (which requires multiple pipelines), i uncovered a segfault that only happens if i connect the bus to a callback for forget to pass one of the callback arguments:
Callback:
```pyth...While trying to test some intervideosrc/sink pipelines (which requires multiple pipelines), i uncovered a segfault that only happens if i connect the bus to a callback for forget to pass one of the callback arguments:
Callback:
```python
def on_eos(bus, msg, pipeline):
print('EOS')
bus.remove_signal_watch()
pipeline.set_state(Gst.State.NULL)
```
Crashes:
```python
sbus.connect('message::eos', on_eos)
```
Does not crash:
```python
sbus.connect('message::eos', on_eos, source)
```
Strangely, it only crashes when starting the pipeline from a Gobject timeout (and not from the start).
Script: [inter.py](/uploads/b55550d50b20b61a0d399422e81049b4/inter.py)
```(gdb) run inter.py
Starting program: /usr/bin/python inter.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
intervideosrc ! compositor ! video/x-raw, format=(string)I420, width=(int)1280, height=(int)720, framerate=(fraction)30/1 ! fpsdisplaysink
videotestsrc is-live=true num-buffers=60 ! video/x-raw, format=(string)I420, width=(int)1280, height=(int)720, framerate=(fraction)30/1 ! intervideosink
[New Thread 0x7ffff390b700 (LWP 19345)]
[New Thread 0x7ffff310a700 (LWP 19346)]
[New Thread 0x7ffff2789700 (LWP 19347)]
[New Thread 0x7ffff1e08700 (LWP 19348)]
Start
Started
(python:19341): GStreamer-CRITICAL **: 11:36:07.165:
Trying to dispose element intervideosink0, but it is in READY instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.
(python:19341): GStreamer-CRITICAL **: 11:36:07.165:
Trying to dispose element capsfilter1, but it is in PLAYING instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.
(python:19341): GStreamer-CRITICAL **: 11:36:07.165:
Trying to dispose element videotestsrc0, but it is in PLAYING instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.
g_mutex_clear() called on uninitialised or locked mutex
sys:1: Warning: g_object_ref: assertion 'object->ref_count > 0' failed
(python:19341): GStreamer-CRITICAL **: 11:36:07.166: gst_object_unref: assertion '((GObject *) object)->ref_count > 0' failed
Thread 1 "python" received signal SIGABRT, Aborted.
0x00007ffff7dcbd7f in raise () from /usr/lib/libc.so.6
(gdb) bt
#0 0x00007ffff7dcbd7f in raise () at /usr/lib/libc.so.6
#1 0x00007ffff7db6672 in abort () at /usr/lib/libc.so.6
#2 0x00007ffff71d3221 in g_mutex_clear () at /usr/lib/libglib-2.0.so.0
#3 0x00007ffff5b5c18b in gst_object_finalize (object=0x5555585d3a00) at ../subprojects/gstreamer/gst/gstobject.c:427
#4 0x00007ffff716d385 in g_object_unref () at /usr/lib/libgobject-2.0.so.0
#5 0x00007ffff5b65da7 in gst_bin_remove_func (bin=0x555555a503d0, element=<optimized out>) at ../subprojects/gstreamer/gst/gstbin.c:1809
#6 0x00007ffff5b64de8 in gst_bin_remove (bin=bin@entry=0x555555a503d0, element=0x5555585d3a00) at ../subprojects/gstreamer/gst/gstbin.c:1871
#7 0x00007ffff5b65073 in gst_bin_dispose (object=0x555555a503d0) at ../subprojects/gstreamer/gst/gstbin.c:527
#8 0x00007ffff716d315 in g_object_unref () at /usr/lib/libgobject-2.0.so.0
#9 0x00007ffff5b9982a in _gst_message_free (message=0x7fffe4002f20) at ../subprojects/gstreamer/gst/gstmessage.c:211
#10 0x00007ffff5b71507 in gst_message_unref (msg=0x7fffe4002f20) at ../subprojects/gstreamer/gst/gstmessage.h:379
#11 0x00007ffff5b71507 in gst_bus_source_dispatch (source=0x555555aae930, callback=0x7ffff5b70660 <gst_bus_async_signal_func>, user_data=0x0) at ../subprojects/gstreamer/gst/gstbus.c:840
#12 0x00007ffff72228d1 in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#13 0x00007ffff72245e9 in () at /usr/lib/libglib-2.0.so.0
#14 0x00007ffff72255c2 in g_main_loop_run () at /usr/lib/libglib-2.0.so.0
#15 0x00007ffff713a6d0 in ffi_call_unix64 () at /usr/lib/libffi.so.6
#16 0x00007ffff713a0a0 in ffi_call () at /usr/lib/libffi.so.6
#17 0x00007ffff7358eb5 in pygi_invoke_c_callable (function_cache=0x555555a55e80, state=<optimized out>, py_args=<optimized out>, py_kwargs=<optimized out>)
at ../subprojects/pygobject/gi/pygi-invoke.c:690
#18 0x00007ffff735a978 in pygi_function_cache_invoke (function_cache=<optimized out>, py_args=py_args@entry=0x7ffff5d980b8, py_kwargs=py_kwargs@entry=0x0)
at ../subprojects/pygobject/gi/pygi-cache.c:863
#19 0x00007ffff7359615 in pygi_callable_info_invoke (user_data=0x0, cache=<optimized out>, kwargs=0x0, py_args=0x7ffff5d980b8, info=<optimized out>)
at ../subprojects/pygobject/gi/pygi-invoke.c:770
#20 0x00007ffff7359615 in _wrap_g_callable_info_invoke (self=<optimized out>, py_args=py_args@entry=0x7ffff72254f0 <g_main_loop_run>, kwargs=kwargs@entry=0x0)
at ../subprojects/pygobject/gi/pygi-invoke.c:770
#21 0x00007ffff734bc1b in _callable_info_call (kwargs=0x0, args=0x7ffff7f8a048, self=0x7ffff5c6ee68) at ../subprojects/pygobject/gi/pygi-info.c:556
#22 0x00007ffff734bc1b in _callable_info_call (self=0x7ffff5c6ee68, args=0x7ffff7f8a048, kwargs=0x0) at ../subprojects/pygobject/gi/pygi-info.c:533
#23 0x00007ffff7b9c63c in _PyObject_FastCallKeywords () at /usr/lib/libpython3.7m.so.1.0
#24 0x00007ffff7be7cca in _PyEval_EvalFrameDefault () at /usr/lib/libpython3.7m.so.1.0
#25 0x00007ffff7b29b99 in _PyEval_EvalCodeWithName () at /usr/lib/libpython3.7m.so.1.0
#26 0x00007ffff7b70492 in _PyFunction_FastCallKeywords () at /usr/lib/libpython3.7m.so.1.0
#27 0x00007ffff7be2c42 in _PyEval_EvalFrameDefault () at /usr/lib/libpython3.7m.so.1.0
#28 0x00007ffff7b29b99 in _PyEval_EvalCodeWithName () at /usr/lib/libpython3.7m.so.1.0
#29 0x00007ffff7b2aab4 in PyEval_EvalCodeEx () at /usr/lib/libpython3.7m.so.1.0
#30 0x00007ffff7b2aadc in PyEval_EvalCode () at /usr/lib/libpython3.7m.so.1.0
#31 0x00007ffff7c54c94 in () at /usr/lib/libpython3.7m.so.1.0
#32 0x00007ffff7c568be in PyRun_FileExFlags () at /usr/lib/libpython3.7m.so.1.0
#33 0x00007ffff7c57c75 in PyRun_SimpleFileExFlags () at /usr/lib/libpython3.7m.so.1.0
#34 0x00007ffff7c59eb7 in () at /usr/lib/libpython3.7m.so.1.0
#35 0x00007ffff7c5a0fc in _Py_UnixMain () at /usr/lib/libpython3.7m.so.1.0
#36 0x00007ffff7db8223 in __libc_start_main () at /usr/lib/libc.so.6
#37 0x000055555555505e in _start ()
```