Segmentation fault on examples/computer_vision/opencvExample

Hi,

i try to run the example for computer_vision/opencvExample on Manjaro Linux (Arch linux based). I always get a segmentation fault on start. Seems like Gstreamer is crashing with OF. It works fine on the system.

GStreamer 1.20.0
https://www.archlinux.org/

Starting program: /home/falko/Downloads/of_v20220320_linux64gcc6_release/examples/computer_vision/opencvExample/bin/opencvExample_debug 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7fffe674d640 (LWP 10282)]
[New Thread 0x7fffe5f4c640 (LWP 10283)]
[New Thread 0x7fffe574b640 (LWP 10284)]
[New Thread 0x7fffe4f4a640 (LWP 10285)]
[New Thread 0x7fffd7fff640 (LWP 10286)]
[New Thread 0x7fffd77fe640 (LWP 10287)]
[New Thread 0x7fffd6ffd640 (LWP 10288)]
[New Thread 0x7fffd67fc640 (LWP 10289)]
[New Thread 0x7fffd5ffb640 (LWP 10290)]
[New Thread 0x7fffd57fa640 (LWP 10291)]
[New Thread 0x7fffd4ff9640 (LWP 10292)]
[New Thread 0x7fffb63ff640 (LWP 10293)]
[New Thread 0x7fffb5bfe640 (LWP 10294)]
[New Thread 0x7fffb53fd640 (LWP 10295)]
[New Thread 0x7fffb4bfc640 (LWP 10296)]
[New Thread 0x7fff92563640 (LWP 10297)]
[New Thread 0x7fff91d62640 (LWP 10298)]
[New Thread 0x7fff91561640 (LWP 10299)]
[New Thread 0x7fff90d60640 (LWP 10300)]
[New Thread 0x7fff9055f640 (LWP 10301)]
[New Thread 0x7fff8fd5e640 (LWP 10302)]
[New Thread 0x7fff8f55d640 (LWP 10303)]
[New Thread 0x7fff8ed5c640 (LWP 10304)]
[New Thread 0x7fff8e55b640 (LWP 10305)]
[New Thread 0x7fff8dd5a640 (LWP 10306)]
[New Thread 0x7fff8d559640 (LWP 10307)]
[New Thread 0x7fff8cd58640 (LWP 10308)]
[New Thread 0x7fff5ffff640 (LWP 10309)]

Thread 29 "vqueue:src" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fff5ffff640 (LWP 10309)]
0x000000000000000a in ?? ()
(gdb) bt
#0  0x000000000000000a in  ()
#1  0x00007ffff7f806f5 in  () at /usr/lib/libgstapp-1.0.so.0
#2  0x00007ffff7e5ca62 in  () at /usr/lib/libgstbase-1.0.so.0
#3  0x00007ffff7d6fcfd in  () at /usr/lib/libgstreamer-1.0.so.0
#4  0x00007ffff7d7039e in  () at /usr/lib/libgstreamer-1.0.so.0
#5  0x00007ffff7d70879 in  () at /usr/lib/libgstreamer-1.0.so.0
#6  0x00007ffff7d663e1 in  () at /usr/lib/libgstreamer-1.0.so.0
#7  0x00007ffff7d73a7b in gst_pad_push_event () at /usr/lib/libgstreamer-1.0.so.0
#8  0x00007ffff7d74045 in  () at /usr/lib/libgstreamer-1.0.so.0
#9  0x00007ffff7d6d87e in gst_pad_forward () at /usr/lib/libgstreamer-1.0.so.0
#10 0x00007ffff7d6d9d6 in gst_pad_event_default () at /usr/lib/libgstreamer-1.0.so.0
#11 0x00007ffff7d6fcfd in  () at /usr/lib/libgstreamer-1.0.so.0
#12 0x00007ffff7d7039e in  () at /usr/lib/libgstreamer-1.0.so.0
#13 0x00007ffff7d70879 in  () at /usr/lib/libgstreamer-1.0.so.0
#14 0x00007ffff7d663e1 in  () at /usr/lib/libgstreamer-1.0.so.0
#15 0x00007ffff7d73a7b in gst_pad_push_event () at /usr/lib/libgstreamer-1.0.so.0
#16 0x00007ffff7d6fcfd in  () at /usr/lib/libgstreamer-1.0.so.0
#17 0x00007ffff7d7039e in  () at /usr/lib/libgstreamer-1.0.so.0
#18 0x00007ffff7d70879 in  () at /usr/lib/libgstreamer-1.0.so.0
#19 0x00007ffff7d663e1 in  () at /usr/lib/libgstreamer-1.0.so.0
#20 0x00007ffff7d73a7b in gst_pad_push_event () at /usr/lib/libgstreamer-1.0.so.0
#21 0x00007ffff7d74045 in  () at /usr/lib/libgstreamer-1.0.so.0
#22 0x00007ffff7d6d87e in gst_pad_forward () at /usr/lib/libgstreamer-1.0.so.0
#23 0x00007ffff7d6d9d6 in gst_pad_event_default () at /usr/lib/libgstreamer-1.0.so.0
#24 0x00007fffe42ba12c in  () at /usr/lib/gstreamer-1.0/libgstplayback.so
#25 0x00007ffff7d6fcfd in  () at /usr/lib/libgstreamer-1.0.so.0
#26 0x00007ffff7d7039e in  () at /usr/lib/libgstreamer-1.0.so.0
#27 0x00007ffff7d70879 in  () at /usr/lib/libgstreamer-1.0.so.0
#28 0x00007ffff7d663e1 in  () at /usr/lib/libgstreamer-1.0.so.0
#29 0x00007ffff7d73a7b in gst_pad_push_event () at /usr/lib/libgstreamer-1.0.so.0
#30 0x00007fffe40fa467 in  () at /usr/lib/gstreamer-1.0/libgstcoreelements.so
#31 0x00007ffff7d99c81 in  () at /usr/lib/libgstreamer-1.0.so.0
#32 0x00007ffff742e7e7 in  () at /usr/lib/libglib-2.0.so.0
#33 0x00007ffff742b815 in  () at /usr/lib/libglib-2.0.so.0
#34 0x00007ffff3f765c2 in start_thread () at /usr/lib/libc.so.6
#35 0x00007ffff3ffb584 in clone () at /usr/lib/libc.so.6

Any ideas how to handle this?

Since I am on linux right now I ran this example to see if I had the same issue. I am on ubuntu 20.4 and it works without any segmentation faults. Did the install codecs and dependencies scripts from this guide run for you? That’s the first place I would start. :v:

1 Like

I have a similar problem that I recently reported:

I don’t know if the cause is the same.

I am running Debian 11 Testing.

Thx for Testing. What Version of GStreamer do you have?

I am very sure i did do a correct installation for for Dependencies. I assume you have a GStreamer version <1.20. Archlinux based Distros are always very bleeding-edge. So it might be that the issue does not exist in the Version used in Ubuntu 20.6

StaffanMelin, did you try using the latest openFrameworks Version from github (Nightly Build)? What Version of GStreamer do you have ?

gst-play-1.0 --version

1 Like

Hi @habales, just downloaded the latest nightly build and tried the videoGrabber example but it still crashes.

It Seg Faults in the call to

vidGrabber.initGrabber()

even though there is a device found.

Looking into this call it is the call to

if( grabber->isInitialized() && bUseTexture ){

that crashes (in ofVideoGrabberg.cpp, line 65).

All previous calls to isInitialised(), calling isLoaded(), seems to return false.

My version of GSreamer is 1.20.0.

This does seem to be a problem with GNU/Linux and gstreamer v 1.20.

For now I have solved my gstreamer issues by violently downgrading everything gstreamer-related, as detailed in my blogpost. Did this on arch linux, which should make it doable on manjaro as well.

2 Likes

have you checked issues on Gstreamer project itself?

Sorry for the late reply here and thank you for the link (that you also posted on the issue: https://github.com/openframeworks/openFrameworks/issues/6871). Great!

For me it doesn’t happen with a video (maybe it does, too) but when capturing from my laptops camera.

Hi, for us too, this issue of currently not accessing videostreams, would be great to get oF support / gstreamer integration, I took a look at the code and try to add some small insights into the issue, hopefully someone with better programming knowledge of gstreamer and oF could help. By the way, ofGstUtils.h looks amazing, #ifdef OF_USE_GST_GL looks great, couldn’t get it to compile due to missing the gstreamer extensions, but looks like very nice, even for playing large videos better performance etc.

Testing with cameras, at the terminal, like StaffanMelin shared, thank you, gstreamer 1.20.0 breaks video on Linux · Issue #6871 · openframeworks/openFrameworks · GitHub

this works

gst-launch-1.0 v4l2src name=video_source device=/dev/video0 ! video/x-raw,format=YUY2,width=320,height=240,framerate=30/1 ! videoconvert ! appsink name=ofappsink enable-last-sample=0 caps=“video/x-raw, format=RGB, width=320, height=240”

doesn’t work

gst-play-1.0 v4l2src name=video_source device=/dev/video0 ! video/x-raw,format=YUY2,width=320,height=240,framerate=30/1 ! videoconvert ! appsink name=ofappsink enable-last-sample=0 caps=“video/x-raw, format=RGB, width=320, height=240”

When oF opens the device I noticed it calls gst-play-1.0, using and was looking for ways to replace it with gst-launch-1.0. From the man pages:

Please note that gst-launch-1.0 is primarily a debugging tool for developers and users. You should not build applications
on top of it. For applications, use the gst_parse_launch() function of the GStreamer API as an easy way to construct pipe‐
lines from pipeline descriptions.

At the moment, this is what is happening in gdb when videoGrabberExample
º

Starting program: /of_v0.11.2_linux64gcc6_release/examples/video/videoGrabberExample/bin/videoGrabberExample 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7fffeaa8f640 (LWP 47522)]
[New Thread 0x7fffea14d640 (LWP 47523)]
[New Thread 0x7fffe994c640 (LWP 47524)]
[New Thread 0x7fffe914b640 (LWP 47525)]
[New Thread 0x7fffe894a640 (LWP 47526)]
[New Thread 0x7fffdbfff640 (LWP 47527)]
[New Thread 0x7fffdb7fe640 (LWP 47528)]
[New Thread 0x7fffdaffd640 (LWP 47529)]
[New Thread 0x7fffda7fc640 (LWP 47530)]
[New Thread 0x7fffd9ffb640 (LWP 47531)]
[New Thread 0x7fffd97fa640 (LWP 47532)]
[New Thread 0x7fffd8ff9640 (LWP 47533)]
[New Thread 0x7fffb7fff640 (LWP 47534)]
[New Thread 0x7fffb77fe640 (LWP 47535)]
[New Thread 0x7fffb6ffd640 (LWP 47536)]
[New Thread 0x7fffb67fc640 (LWP 47537)]
[notice ] ofGstVideoGrabber: Probing devices with udev...
[notice ] ofGstVideoGrabber: Found device 0408:5365, getting capabilities...
[notice ] ofGstVideoGrabber: detected v4l2 device:
[notice ] ofGstVideoGrabber: driver: uvcvideo, version: 331027
[notice ] ofGstVideoGrabber: Capabilities: 0x84A00001
[notice ] ofGstVideoGrabber: Found device 0408:5365, getting capabilities...
[notice ] ofGstVideoGrabber: detected v4l2 device: 
[notice ] ofGstVideoGrabber: driver: uvcvideo, version: 331027
[notice ] ofGstVideoGrabber: Capabilities: 0x84A00001
[notice ] device /dev/video1 seems to not have the capture capability, (radio tuner/metadata device?)
[notice ] removing it from device list
[notice ] 0: 
[notice ] ofGstVideoGrabber: initGrabber(): selected device: 
[notice ] ofGstVideoGrabber: initGrabber(): selected format: 320x240 video/x-raw YUY2 framerate: 30/1
[New Thread 0x7fffb5bfb640 (LWP 47539)]
[notice ] ofGstUtils: setPipelineWithSink(): gstreamer pipeline: v4l2src name=video_source device=/dev/video0 ! video/x-raw,format=YUY2,width=320,height=240,framerate=30/1  ! videoconvert   ! appsink name=ofappsink enable-last-sample=0 caps="video/x-raw, format=RGB, width=320, height=240"
[New Thread 0x7fffb53fa640 (LWP 47540)]

Thread 19 "video_source:sr" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffb53fa640 (LWP 47540)]
0x000000000000000a in ?? ()
(gdb) bt
#0  0x000000000000000a in  ()
#1  0x00007ffff7f81739 in  () at /usr/lib/libgstapp-1.0.so.0
#2  0x00007ffff7e5ab52 in  () at /usr/lib/libgstbase-1.0.so.0
#3  0x00007ffff7d6b7ed in  () at /usr/lib/libgstreamer-1.0.so.0
#4  0x00007ffff7d6be8e in  () at /usr/lib/libgstreamer-1.0.so.0
#5  0x00007ffff7d6c369 in  () at /usr/lib/libgstreamer-1.0.so.0
#6  0x00007ffff7d61f21 in  () at /usr/lib/libgstreamer-1.0.so.0
#7  0x00007ffff7d6f56b in gst_pad_push_event () at /usr/lib/libgstreamer-1.0.so.0
#8  0x00007ffff7d6b7ed in  () at /usr/lib/libgstreamer-1.0.so.0
#9  0x00007ffff7d6be8e in  () at /usr/lib/libgstreamer-1.0.so.0
#10 0x00007ffff7d6c369 in  () at /usr/lib/libgstreamer-1.0.so.0
#11 0x00007ffff7d61f21 in  () at /usr/lib/libgstreamer-1.0.so.0
#12 0x00007ffff7d6f56b in gst_pad_push_event () at /usr/lib/libgstreamer-1.0.so.0
#13 0x00007fffd819885d in  () at /usr/lib/gstreamer-1.0/libgstcoreelements.so
#14 0x00007ffff7d6b7ed in  () at /usr/lib/libgstreamer-1.0.so.0
#15 0x00007ffff7d6be8e in  () at /usr/lib/libgstreamer-1.0.so.0
#16 0x00007ffff7d6c369 in  () at /usr/lib/libgstreamer-1.0.so.0
#17 0x00007ffff7d61f21 in  () at /usr/lib/libgstreamer-1.0.so.0
#18 0x00007ffff7d6f56b in gst_pad_push_event () at /usr/lib/libgstreamer-1.0.so.0
#19 0x00007ffff7e8ac72 in  () at /usr/lib/libgstbase-1.0.so.0
#20 0x00007ffff7e70e40 in  () at /usr/lib/libgstbase-1.0.so.0
#21 0x00007ffff7d95af1 in  () at /usr/lib/libgstreamer-1.0.so.0
#22 0x00007ffff73c5de7 in  () at /usr/lib/libglib-2.0.so.0
#23 0x00007ffff73c2da5 in  () at /usr/lib/libglib-2.0.so.0
#24 0x00007ffff6d1954d in  () at /usr/lib/libc.so.6
#25 0x00007ffff6d9eb14 in clone () at /usr/lib/libc.so.6
(gdb) 


Would be great to find a way

1 Like

Looks like there is still live depth feeds from kinects, so that is ok for now. Takes a while to boot, RGB too. Will have a look at gstreamer when there is time., there’s also v4l so

make run
[verbose] ofxKinect: context inited
[warning] ofxKinect: no available devices found
[warning] ofxKinect: update(): device -1 isn't delivering data. depth: 0 color: 0  , reconnecting tries: 1
[verbose] ofxKinect: device 0  connection opened
[Stream 70] Expected max 1748 data bytes, but got 1908. Dropping...
[Stream 70] Expected max 1748 data bytes, but got 1908. Dropping...
[verbose] ofxKinect: device 0 connection closed
[warning] ofxKinect: update(): device -1 isn't delivering data. depth: 1 color: 0  , reconnecting tries: 1
[verbose] ofxKinect: device 0  connection opened

1 Like

Amazing guide! Just followed along and your way fixed the problem.

For anyone interested, this little cursed command will save you some time and manual labor when installing the older versions of all the gstreamer related packages manually:

for package in $(curl https://archive.archlinux.org/packages/g/ | grep gst | grep -Po 'href="\K[^/"]*'); do echo $package; sudo pacman -Udd "https://archive.archlinux.org/packages/g/${package}/${package}-1.18.5-1-x86_64.pkg.tar.zst"; done

What it does is look for anything with gst in the package archive, then extracting the package name from the html page, and finally, it constructs the url to the package in the correct version (1.18.5-1), and installs it with pacman.

Some packages are not found, and it’s ok, it worked for me without them.

Thanks for sharing your solution kflak1!

Glad you found it useful! And your bash one-liner is a thing of beauty :slight_smile:

Unfortunately I had to catch up with the times again after the downgrade, as all kinds of gui stuff in other applications started breaking. For the moment I keep my video laptop frozen at ca. february 2022, and cross my fingers that someone will manage to find a solution (either by managing to link 1.18 directly in the oF apps, or by supporting hardware acceleration…), and if I need a simple video-dependent app I will rather use processing on my daily driver laptop. They actually bundled 1.18 very quickly after the bug became obvious.

Just want to echo that with a 20.04 Mint setup it works out of the box too.
Using the scripts/ubuntu/install_dependencies.sh installs gstreamer 1.0 - so I think the issue is if you later update gstreamer to a newer version or if you gave gstreamer 1.20.0 or newer installed prior to installing OF.

We should work on getting hardware acceleration working with OF but nice to have the grep solution in the meantime.

We should maybe add a note though to the ofSite / Linux setup instructions mentioning OF requires gstreamer 1.18 or older.