compositor: segfault when source changes size
As workaround to #707 (closed) I've started using videoscale
. However, with certain incoming video size changes I'm getting segfaults (but not with others). GStreamer from Ubuntu 18.10 repos.
Reproducible demo:
Cargo.toml:
[package]
name = "gstreamer-resize-bug-demo"
version = "0.1.0"
authors = ["Nazar Mokrynskyi <nazar@mokrynskyi.com>"]
edition = "2018"
[dependencies]
gstreamer = "0.15.0"
src/main.rs:
use gstreamer::init;
use gstreamer::prelude::*;
use gstreamer::Caps;
use gstreamer::Element;
use gstreamer::ElementFactory;
use gstreamer::MessageView;
use gstreamer::Pipeline;
use gstreamer::State;
use gstreamer::CLOCK_TIME_NONE;
use std::io::Result;
fn main() -> Result<()> {
init().unwrap();
let pipeline = Pipeline::new(None);
let video = ElementFactory::make("videotestsrc", None).unwrap();
let videoscale = ElementFactory::make("videoscale", None).unwrap();
let capsfilter = ElementFactory::make("capsfilter", None).unwrap();
let compositor = ElementFactory::make("compositor", None).unwrap();
let autovideosink = ElementFactory::make("autovideosink", None).unwrap();
pipeline
.add_many(&[
&video,
&videoscale,
&capsfilter,
&compositor,
&autovideosink,
])
.unwrap();
capsfilter
.set_property(
"caps",
&Caps::new_simple("video/x-raw", &[("width", &1918), ("height", &538)]),
)
.unwrap();
Element::link_many(&[&video, &videoscale, &capsfilter]).unwrap();
Element::link_many(&[&compositor, &autovideosink]).unwrap();
let compositor_sink_pad = compositor.get_request_pad("sink_%u").unwrap();
compositor_sink_pad.set_property("height", &1078).unwrap();
compositor_sink_pad.set_property("width", &1918).unwrap();
capsfilter
.get_static_pad("src")
.unwrap()
.link(&compositor_sink_pad)
.unwrap();
pipeline.set_state(State::Playing).unwrap();
std::thread::sleep(std::time::Duration::from_secs(1));
capsfilter
.set_property(
"caps",
&Caps::new_simple("video/x-raw", &[("width", &1918), ("height", &430)]),
)
.unwrap();
let bus = pipeline.get_bus().unwrap();
for msg in bus.iter_timed(CLOCK_TIME_NONE) {
match msg.view() {
MessageView::Eos(..) => break,
MessageView::Error(err) => {
println!(
"Error from {:?}: {} ({:?})",
err.get_src().map(|s| s.get_path_string()),
err.get_error(),
err.get_debug()
);
break;
}
_ => (),
}
}
pipeline.set_state(State::Null).unwrap();
Ok(())
}
Backtrace of above test program looks like this:
Thread 4 "compositor0:src" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff6aaf700 (LWP 3776)]
0x00007ffff7669fb9 in ?? ()
(gdb) bt
#0 0x00007ffff7669fb9 in ()
#1 0x00007ffff786b2a6 in video_orc_resample_v_2tap_u8_lq (d1=0x7fffe833d220 "", s1=0x7fffec3d4bc0 "", s2=0x7fffec3d4f80 "", p1=88, n=959) at tmp-orc.c:23371
#2 0x00007ffff7835257 in gst_video_scaler_2d (hscale=<optimized out>, vscale=<optimized out>, format=<optimized out>, src=0x7fffec3a1a40, src_stride=960, dest=<optimized out>, dest_stride=960, x=0, y=0, width=<optimized out>, height=539) at video-scaler.c:1506
#3 0x00007ffff7821d07 in convert_plane_hv_task (task=<optimized out>) at video-converter.c:5720
#4 0x00007ffff781e80f in gst_parallelized_task_runner_run (self=self@entry=0x7fffe800dad0, func=func@entry=0x7ffff7821cd0 <convert_plane_hv_task>, task_data=task_data@entry=0x7ffff6aae310) at video-converter.c:297
#5 0x00007ffff7820740 in convert_plane_hv (convert=<optimized out>, src=<optimized out>, dest=<optimized out>, plane=<optimized out>) at video-converter.c:5783
#6 0x00007ffff782aadd in convert_scale_planes (convert=0x7fffe800d360, src=0x7ffff6aae420, dest=0x7ffff6aae6c0) at video-converter.c:5796
#7 0x00007ffff7836b00 in gst_video_aggregator_convert_pad_prepare_frame (vpad=0x55555577a520 [GstVideoAggregatorPad|sink_0], vagg=0x5555557639a0 [GstVideoAggregator|compositor0], buffer=<optimized out>, prepared_frame=0x55555577a078) at gstvideoaggregator.c:455
#8 0x00007ffff78bfe4f in gst_compositor_pad_prepare_frame (pad=0x55555577a520 [GstVideoAggregatorPad|sink_0], vagg=0x5555557639a0 [GstVideoAggregator|compositor0], buffer=0x7fffe8010120, prepared_frame=0x55555577a078) at compositor.c:409
#9 0x00007ffff7ebca96 in gst_element_do_foreach_pad
(element=element@entry=0x5555557639a0 [GstElement|compositor0], func=func@entry=0x7ffff78356d0 <prepare_frames>, user_data=user_data@entry=0x0, p_pads=p_pads@entry=0x555555763a78, p_npads=p_npads@entry=0x555555763a70) at gstelement.c:1272
#10 0x00007ffff7ebe897 in gst_element_foreach_sink_pad (element=element@entry=0x5555557639a0 [GstElement|compositor0], func=func@entry=0x7ffff78356d0 <prepare_frames>, user_data=user_data@entry=0x0) at gstelement.c:1305
#11 0x00007ffff783a849 in gst_video_aggregator_do_aggregate (outbuf=0x7ffff6aaeb60, output_end_time=1200000000 [0:00:01.200000000], output_start_time=1166666667 [0:00:01.166666667], vagg=0x5555557639a0 [GstVideoAggregator|compositor0]) at gstvideoaggregator.c:1674
#12 0x00007ffff783a849 in gst_video_aggregator_aggregate (agg=0x5555557639a0 [GstAggregator|compositor0], timeout=0) at gstvideoaggregator.c:1851
#13 0x00007ffff7793160 in gst_aggregator_aggregate_func (self=0x5555557639a0 [GstAggregator|compositor0]) at gstaggregator.c:1157
#14 0x00007ffff7f10097 in gst_task_func (task=0x555555790050 [GstTask|compositor0:src]) at gsttask.c:328
#15 0x00007ffff7d54854 in () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#16 0x00007ffff7d54111 in () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#17 0x00007ffff7cb9669 in start_thread (arg=<optimized out>) at pthread_create.c:479
#18 0x00007ffff7bc5323 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
With more complex app where I discovered segdault initially I'm getting slightly different backtrace, maybe it is useful (or potentially a different cause, don't know for sure):
Thread 78 "compositor1:src" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffa97fa700 (LWP 31053)]
0x00007ffff40cdc54 in ?? ()
(gdb) bt
#0 0x00007ffff40cdc54 in ()
#1 0x00007ffff440ca7e in video_orc_convert_I420_ARGB
(d1=0x7fff2841f940 "\377", s1=0x7ffef5c57050 "\201\201\200\200\177~~~\177\177\177\177\177\200\200\200\201\201\204\205\205\203\202\201\200\200\200\200\200\200\200\200\177}~\177\200\201\202\202\203\203\203\204\204\203\202\202\201\201\201\201\201\201\201\201\200\200\200\200\200\200\200\200\177\177\177\200\200\200\200\200\177\177\177}~\206\202\177~\200\200\200\200\177~}}~\177\200\200\201\201\202\203\203\201\200\177~}~\177\200\200\200\200\200\200\200\200\200\200\177\177~~~~~\177\177\177\200\200\201\201\203\202\202\201\177\177\177\177\177", '\200' <\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377 30 \377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377.>, "\177\177\200\201\201\201\201\200\200\200\201\201\201\203\205\205\206\206\204\203\202\201\201\201\201\201\201\201\201\201\202\202"..., s2=0x7ffef5c86990 '\200' <\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377 200 \377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377.>..., s3=0x7ffef5cb8fd0 "", p1=298, p2=409, p3=516, p4=-100, p5=-208, n=1918) at tmp-orc.c:22281
#2 0x00007ffff43c2b16 in convert_I420_pack_ARGB_task (task=0x7fffa97f8ef0) at video-converter.c:5131
#3 0x00007ffff43c080f in gst_parallelized_task_runner_run (self=self@entry=0x7fff280010d0, func=func@entry=0x7ffff43c2a00 <convert_I420_pack_ARGB_task>, task_data=task_data@entry=0x7fffa97f8ee0) at video-converter.c:297
#4 0x00007ffff43c845f in convert_I420_pack_ARGB (convert=<optimized out>, src=<optimized out>, dest=0x7fffa97f9270) at video-converter.c:5188
#5 0x00007ffff43d8b00 in gst_video_aggregator_convert_pad_prepare_frame (vpad=0x7ffef401add0 [GstVideoAggregatorPad|sink_2], vagg=0x7fffe8025030 [GstVideoAggregator|compositor1], buffer=<optimized out>, prepared_frame=0x7ffef401a928) at gstvideoaggregator.c:455
#6 0x00007ffff4461e4f in gst_compositor_pad_prepare_frame (pad=0x7ffef401add0 [GstVideoAggregatorPad|sink_2], vagg=0x7fffe8025030 [GstVideoAggregator|compositor1], buffer=0x7fff9c2b57e0, prepared_frame=0x7ffef401a928) at compositor.c:409
#7 0x00007ffff7eb0a96 in gst_element_do_foreach_pad
(element=element@entry=0x7fffe8025030 [GstElement|compositor1], func=func@entry=0x7ffff43d76d0 <prepare_frames>, user_data=user_data@entry=0x0, p_pads=p_pads@entry=0x7fffe8025108, p_npads=p_npads@entry=0x7fffe8025100) at gstelement.c:1272
#8 0x00007ffff7eb2897 in gst_element_foreach_sink_pad (element=element@entry=0x7fffe8025030 [GstElement|compositor1], func=func@entry=0x7ffff43d76d0 <prepare_frames>, user_data=user_data@entry=0x0) at gstelement.c:1305
#9 0x00007ffff43dc849 in gst_video_aggregator_do_aggregate (outbuf=0x7fffa97f9720, output_end_time=13866666667 [0:00:13.866666667], output_start_time=13833333333 [0:00:13.833333333], vagg=0x7fffe8025030 [GstVideoAggregator|compositor1])
at gstvideoaggregator.c:1674
#10 0x00007ffff43dc849 in gst_video_aggregator_aggregate (agg=0x7fffe8025030 [GstAggregator|compositor1], timeout=1) at gstvideoaggregator.c:1851
#11 0x00007ffff7646160 in gst_aggregator_aggregate_func (self=0x7fffe8025030 [GstAggregator|compositor1]) at gstaggregator.c:1157
#12 0x00007ffff7f04097 in gst_task_func (task=0x7fff9c2b7170 [GstTask|compositor1:src]) at gsttask.c:328
#13 0x00007ffff7d48854 in () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#14 0x00007ffff7d48111 in () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#15 0x00007ffff7c92669 in start_thread (arg=<optimized out>) at pthread_create.c:479
#16 0x00007ffff7ba0323 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Edited by Nazar Mokrynskyi