Camera widget using gstreamer end up with segfault on imx8mp
Software Versions
- Python: 3.10.7
- OS: Linux
- Kivy: v2.1.0.dev0
- Kivy installation method: Yocto (Kirkstone)
Describe the bug Hello ! First of all, I am working on embedded device (imx8mp) and I have a problem when I try to use Gstreamer with a USB camera. I use the camera's demo program of Kivy (link here) but end up with a segfault as you can see on this log: https://gist.github.com/MarineVovard/c7b32c4fcdc28c679f6339c939b1ec68
Expected behavior No segfault and camera running after clicking on the start button.
After examining the camera_gi.py file in the core folder, I found out that the following lines were the problem:
# We cannot get the data out of mapinfo, using Gst 1.0.6 + Gi 3.8.0
# related bug report:
# https://bugzilla.gnome.org/show_bug.cgi?id=6t8663
# ie: mapinfo.data is normally a char*, but here, we have an int
# So right now, we use ctypes instead to read the mapinfo ourself.
addr = mapinfo.__hash__()
c_mapinfo = _MapInfo.from_address(addr)
# now get the memory
self._buffer = string_at(c_mapinfo.data, mapinfo.size)
So I change that part by this line and it works for me now:
self._buffer = bytes(mapinfo.data)
To Reproduce Run the kivy demo for camera with Gstreamer provider on imx8 ? I also tried to reproduce the error on Ubuntu but the actual implementation seems to work just fine.
I also tried my solution on Ubuntu and it seems to work too.
Additional context
It is indicated in the camera_gi.py file that the lines I removed were necessary to fix a bug when using Gst 1.0.6 + Gi 3.8.0.
I tried to obtain more information on the bug but the link seems to be broken. I did not find any other issue related to this problem on Internet either. I checked the git blame and the code is 10 years old so that could explain the absence of information on this bug.
I am wondering if this conversion to a ctype is still necessary and if people still use Gst 1.0.6. Could it be interesting to remove this conversion to ctype for everyone ?
I have the same issue with a microsoft USB webcam. This used to work, but after upgrading the OS to Ubuntu 22.04 it started to core dump. The fix above also fixed it for me.