aggregator: Crash when adding random pads
- GStreamer version 1.20.3 Fedora 36
- crate version: 0.18.8
Adding and linking arbitrary pads to elements with multiple 'request-pads' like audiomixer
leads to a SIGSEGV.
Swapping audiomixer name=sink_element ! fakesink
with fakesink name=sink_element
gets rid of the crash and instead (as expected) yields an Internal data stream error.
use gstreamer as gst;
use gst::prelude::*;
fn main() {
gst::init().unwrap();
let pipeline = gst::parse_launch("
audiotestsrc name=src_element
audiomixer name=sink_element ! fakesink
").unwrap();
let pipeline = pipeline.downcast::<gst::Pipeline>().unwrap();
let src_element = pipeline.by_name("src_element").unwrap();
let src = src_element.static_pad("src").unwrap();
let sink_element = pipeline.by_name("sink_element").unwrap();
// Create a new pad and add it to the sink_element
let problematic_pad = gst::Pad::new(None, gst::PadDirection::Sink);
sink_element.add_pad(&problematic_pad).unwrap();
// then link the pad to the source
src.link(&problematic_pad).unwrap();
pipeline.set_state(gst::State::Playing).unwrap();
let bus = pipeline.bus().unwrap();
for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView;
match msg.view() {
MessageView::Error(err) => {
break;
}
MessageView::Eos(..) => break,
_ => (),
}
}
}
Valgrind output
==285970== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==285970== Access not within mapped region at address 0x150
==285970== at 0x4AC2469: g_mutex_lock (gthread-posix.c:1516)
==285970== by 0x5581179: gst_aggregator_do_events_and_queries (gstaggregator.c:946)
==285970== by 0x493A9D7: gst_element_do_foreach_pad (gstelement.c:1403)
==285970== by 0x5588906: gst_aggregator_aggregate_func (gstaggregator.c:1372)
==285970== by 0x4987590: gst_task_func (gsttask.c:384)
==285970== by 0x4A9ED01: g_thread_pool_thread_proxy.lto_priv.0 (gthreadpool.c:354)
==285970== by 0x4A9C301: g_thread_proxy (gthread.c:827)
==285970== by 0x4CE5E2C: start_thread (pthread_create.c:442)
==285970== by 0x4D6A363: clone (clone.S:100)