Unexpected Segmentation faults when writing a GStreamer element in Python with custom properties

MathieuP mathieu.pierfitte at nirovision.com
Wed May 15 01:10:51 UTC 2019


I have been experimenting weird Segmentation faults in the past when writing
GStreamer elements in Python using gst-python. I still have some elements
causing issues, but I can't share the source code with you unfortunately,
and I couldn't figure out which line(s) is(are) causing this to happen so I
can't share a simple way to reproduce it either.

I'll just try to describe the problem as clearly as I can here.

As of today, all of the elements I have in my codebase are fine. Most of
them are declaring custom properties, and I have been using the Pythonic way
to do it (using annotation @GObject.Property with the appropriate type,
default, min/max, ...) as well as the C way (adding the __gproperties__
field and defining getters/setters for each property). No matter the method
I chose, the result is the same: they all work fine for all kind of elements
(srcs, sinks, ALWAYS/ON_REQUEST/SOMETIMES pads, ...).

However, sometimes, when I add a property to an element that works just
fine, the element starts "Segmentation faulting" for no apparent reason. I
have experienced this with multiple properties types / defaults / mins /
maxs, and switching between the Pythonic definition or the properties and
the C-style definition doesn't change anything.

What I am experimenting is, I can't even gst-inspect-1.0 the element without
a Segmentation fault showing up when listing the properties. I got this line
showing up right before the flags of the property are listed:

and then a Segmentation fault. gst-launch-1.0 obviously won't work either.

What I have tested so far is:

- Enabling core dumps to track down who is causing this Segmentation fault.
It didn't give me anything, really.

- Adding a Gst.init(None) at the top of the Python file doesn't change
anything

- Adding a "import pdb; pdb.set_trace()" statement at the end of the
__init__ method of the element. This way, I can make sure the element and
its properties are all initialized fine. Then I just hit "c" to continue
executing the code. Proceeding this way *actually does get rid of the
Segmentation fault*. Unfortunately, I can't go to prod with this
workaround...

- For this reason, I assumed replacing the "import pdb; pdb.set_trace()" +
"c" trick with a good old "time.sleep(1)" should do the trick as well.
Unfortunately, the Segmentation fault is back...

- Lately, I've noticed declaring a fake sinkpad with a chain function in the
__init__ method also gets rid of the Segmentation fault, even though I'm
never actually using this sinkpad:


So far, I don't have any better solution than this last point. However, I
obviously don't feel confident going to prod with a weird behaviour I can't
explain in my elements. Any hint on how to solve this?



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/


More information about the gstreamer-devel mailing list