Bug in GStreamer, mark MessageRef::get_src() unsafe?
Created by: rikte88
When running a playbin, It turns out that messages exist on the bus where the message src pointer is invalid. (already freed or something)
Checking if msg.get_src() == pipeline sometimes causes memory corruption that will crash the program at a later time.
This is of course not a problem with this excellent library, but possibly MessageRef::get_src() should be unsafe with a warning until this gets fixed in GStreamer?
This is the reason for the bug that i filed earlier: https://github.com/sdroege/gstreamer-rs/issues/70
I managed to work around this limitation in the following way:
// let msg_from_pipeline = msg.get_src().unwrap() == pipeline; // DON'T DO THIS
let msg_from_pipeline = unsafe { // WORKAROUND
use glib::translate::ToGlibPtr;
use gstreamer_sys::{GstElement, GstPipeline};
let pipeline_ptr: *const GstPipeline = pipeline.to_glib_none().0;
let msg_src_ptr = (*msg.as_ptr()).src as *const GstElement;
pipeline_ptr as *const GstElement == msg_src_ptr
};
With the workaround, all problems go away and it works flawlessly.
Tested on Fedora 27 with: [karlri@localhost ~]$ gst-launch-1.0 --version gst-launch-1.0 version 1.12.4 GStreamer 1.12.4 http://download.fedoraproject.org