Using `nvcompositor` with `nvarguscamerasrc` leads to segfault in `nvcompositor`

Hi, I am running into segfaults in the nvcompositor when using it to compose buffers from nvarguscamerasrc.

I have this minimal example that segfaults every time. When run in GDB the example shows that it segfaults somewhere inside /usr/lib/gstreamer-1.0/libgstnvcompositor.so
Because I do not have the source of that .so-file, I can not debug this further.

#!/bin/bash

gst-launch-1.0 \
  nvcompositor name=comp ! \
  'video/x-raw(memory:NVMM),width=(int)4056,height=(int)3040,framerate=30/1,format=(string)RGBA' ! \
  fakesink \
  nvarguscamerasrc sensor-id=0 ! \
  'video/x-raw(memory:NVMM),width=(int)4056,height=(int)3040,framerate=30/1,format=(string)NV12' ! \
  comp.sink_0 \

If I replace the nvarguscamerasrc with a videotestsrc combined with a nvvidconv to upload the buffer to NVMM memory, the thing works flawlessly.

#!/bin/bash

gst-launch-1.0 \
  nvcompositor name=comp ! \
  'video/x-raw(memory:NVMM),width=(int)4056,height=(int)3040,framerate=30/1,format=(string)RGBA' ! \
  fakesink \
  videotestsrc ! \
  'video/x-raw,width=(int)4056,height=(int)3040,framerate=30/1,format=(string)NV12' ! \
  nvvidconv ! \
  'video/x-raw(memory:NVMM),width=(int)4056,height=(int)3040,framerate=30/1,format=(string)NV12' ! \
  comp.sink_0 \

I am running this on an Nvidia Xavier AGX, using a 4K camera from Leopard Imaging.

Here is gst-inspect-1.0 for nvarguscamerasrc and nvcompositor:

Factory Details:
  Rank                     primary (256)
  Long-name                NvArgusCameraSrc
  Klass                    Video/Capture
  Description              nVidia ARGUS Camera Source
  Author                   Viranjan Pagar <vpagar@nvidia.com>, Amit Pandya <apandya@nvidia.com>

Plugin Details:
  Name                     nvarguscamerasrc
  Description              nVidia ARGUS Source Component
  Filename                 /usr/lib/gstreamer-1.0/libgstnvarguscamerasrc.so
  Version                  1.0.0
  License                  Proprietary
  Source module            nvarguscamerasrc
  Binary package           NvARGUSCameraSrc
  Origin URL               http://nvidia.com/
Factory Details:
  Rank                     primary + 1 (257)
  Long-name                NvCompositor
  Klass                    Filter/Video/Compositor
  Description              Composite multiple video frames
  Author                   Amit Pandya <apandya@nvidia.com>

Plugin Details:
  Name                     nvcompositor
  Description              Video Compositor
  Filename                 /usr/lib/gstreamer-1.0/libgstnvcompositor.so
  Version                  1.16.3
  License                  Proprietary
  Source module            gstreamer-nvcompositor-plugin
  Binary package           GStreamer NvCompositor Plugin
  Origin URL               http://nvidia.com/

One important detail is that I am running on a custom yocto-based linux image, based of the official meta-tegra yocto layer. This is the specific commit we are using for meta-tegra: GitHub - OE4T/meta-tegra at 1612b9f9b1446e6e46c42172b1d07efcfa02ac1c

This means we are using recipes-bsp/tegra-sources/tegra-sources-35.2.1.inc which in turn means we are using L4T-35.2.1
References:
nvarguscamerasrc: meta-tegra/gstreamer1.0-plugins-nvarguscamerasrc_1.0.0-r35.2.1.bb at 1612b9f9b1446e6e46c42172b1d07efcfa02ac1c · OE4T/meta-tegra · GitHub
nvcompositor: meta-tegra/gstreamer1.0-plugins-nvcompositor_1.20.5-r35.2.1.bb at 1612b9f9b1446e6e46c42172b1d07efcfa02ac1c · OE4T/meta-tegra · GitHub

@DaneLLL You are an expert on these kinds of things, does this ring any bell to you, any missing information I can supply to dig into this issue?

Hi,
Please send RGBA buffer to nvcompositor and check if the issue is present.

Besides, nvcompositor plugin is open source. You can download the source code package and manually build the plugin.

Thank you for the very quick feedback.

I am sorry. I mixed up nvcompositor with another closed source element.
I am working as we speak to get debugging symbols built on our yocto build server to give GDB a full trace.
In the mean time, I changed the minimal non-working example to do RGBA input to nvcompositor.

#!/bin/bash

export GST_DEBUG=2
gdb -ex r --args gst-launch-1.0 \
  nvcompositor name=comp ! \
  'video/x-raw(memory:NVMM),width=(int)4056,height=(int)3040,framerate=30/1,format=(string)RGBA' ! \
  fakesink \
  nvarguscamerasrc sensor-id=0 ! \
  'video/x-raw(memory:NVMM),width=(int)4056,height=(int)3040,framerate=30/1,format=(string)NV12' ! \
  nvvidconv ! \
  'video/x-raw(memory:NVMM),width=(int)4056,height=(int)3040,framerate=30/1,format=(string)RGBA' ! \
  comp.sink_0 \

When run, it segfaults with this output:

benchtop-morten:~$ sudo ./minimal_example_rgba.sh 
GNU gdb (GDB) 11.2
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "aarch64-poky-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from gst-launch-1.0...
Reading symbols from /usr/bin/.debug/gst-launch-1.0...
Starting program: /usr/bin/gst-launch-1.0 nvcompositor name=comp \! video/x-raw\(memory:NVMM\),width=\(int\)4056,height=\(int\)3040,framerate=30/1,format=\(string\)RGBA \! fakesink nvarguscamerasrc sensor-id=0 \! video/x-raw\(memory:NVMM\),width=\(int\)4056,height=\(int\)3040,framerate=30/1,format=\(string\)NV12 \! nvvidconv \! video/x-raw\(memory:NVMM\),width=\(int\)4056,height=\(int\)3040,framerate=30/1,format=\(string\)RGBA \! comp.sink_0
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
warning: the debug information found in "/usr/lib/gstreamer-1.0/.debug/libgstnvcompositor.so" does not match "/usr/lib/gstreamer-1.0/libgstnvcompositor.so" (CRC mismatch).

[New Thread 0xffffec091120 (LWP 695938)]
warning: the debug information found in "/usr/lib/gstreamer-1.0/.debug/libgstnvarguscamerasrc.so" does not match "/usr/lib/gstreamer-1.0/libgstnvarguscamerasrc.so" (CRC mismatch).

[New Thread 0xffffea01f120 (LWP 695940)]
warning: the debug information found in "/usr/lib/gstreamer-1.0/.debug/libgstnvvidconv.so" does not match "/usr/lib/gstreamer-1.0/libgstnvvidconv.so" (CRC mismatch).

Setting pipeline to PAUSED ...
[New Thread 0xffffe972f120 (LWP 695941)]
[New Thread 0xffffe8f1f120 (LWP 695942)]
Pipeline is live and does not need PREROLL ...
[New Thread 0xffffe3fff120 (LWP 695943)]
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
0:00:00.528576893 695935 0xaaaaaaabbb60 WARN         videoaggregator gstvideoaggregator.c:1144:gst_video_aggregator_find_best_format:<comp> Nothing compatible with video/x-raw(memory:NVMM), format=(string)RGBA, width=(int)4056, height=(int)3040, framerate=(fraction)30/1
[New Thread 0xffffe37ef120 (LWP 695944)]

Thread 4 "comp:src" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xffffe972f120 (LWP 695941)]
0x0000fffff79357dc in ?? () from /usr/lib/gstreamer-1.0/libgstnvcompositor.so
(gdb) bt
#0  0x0000fffff79357dc in ?? () from /usr/lib/gstreamer-1.0/libgstnvcompositor.so
#1  0x0000fffff610bb04 in gst_aggregator_default_negotiate (self=0xaaaaaad4b2a0) at ../gstreamer-1.20.4/libs/gst/base/gstaggregator.c:1281
#2  0x0000fffff610c924 in gst_aggregator_negotiate_unlocked (self=0xaaaaaad4b2a0)
    at ../gstreamer-1.20.4/libs/gst/base/gstaggregator.c:1321
#3  gst_aggregator_aggregate_func (self=<optimized out>) at ../gstreamer-1.20.4/libs/gst/base/gstaggregator.c:1391
#4  0x0000fffff7f0c3e4 in gst_task_func (task=0xaaaaaadaf050) at ../gstreamer-1.20.4/gst/gsttask.c:384
#5  0x0000fffff7d64ec8 in g_thread_pool_thread_proxy (data=<optimized out>) at ../glib-2.72.3/glib/gthreadpool.c:354
#6  0x0000fffff7d64338 in g_thread_proxy (data=0xaaaaaaabbb60) at ../glib-2.72.3/glib/gthread.c:827
#7  0x0000fffff7b302a8 in start_thread (arg=0xffffffffec07) at pthread_create.c:442
#8  0x0000fffff7b97bdc in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:79
(gdb) 

It seems RGBA itself does not help it avoid the segfault.

Hi,
Please try Xavier + default rootfs. We can run the command successfully:

gst-launch-1.0 \
  nvcompositor name=comp ! \
  'video/x-raw(memory:NVMM),width=(int)2592,height=(int)1944,framerate=30/1,format=(string)RGBA' ! \
  fakesink \
  nvarguscamerasrc sensor-id=0 ! \
  'video/x-raw(memory:NVMM),width=(int)2592,height=(int)1944,framerate=30/1,format=(string)NV12' ! \
  nvvidconv ! \
  'video/x-raw(memory:NVMM),width=(int)2592,height=(int)1944,framerate=30/1,format=(string)RGBA' ! \
  comp.sink_0

The camera sensor is ov5693 which has maximum resolution 2592x1944, so we modify the resolution and can run it successfully. You may give it a try. Probably the issue is due to Yocto rootfs and certain libs are missing or mismatched.

Interesting.
Could you share which L4T version your working machine is running?
Also, could you share the exact versions of gstreamer running on your platform?

Hi,
We try it on Xavier developer kit + Jetpack 5.1.1. The gstreamer version in default release is 1.16.3.
It is supposed to work on Xavier developer kit + default Jetpack 5.1. Are you able to give it a try?

I can confirm that my own example works on my devkit using this release:

# R35 (release), REVISION: 1.0, GCID: 31346300, BOARD: t186ref, EABI aarch64, DATE: Thu Aug 25 18:41:45 UTC 2022

So I guess the interesting question is what the difference is then.

Hi,
For using Yocto rootfs, you may consider check with RidgeRun. Please take a look at
Yocto Support for NVIDIA Jetson Platforms - Yocto Support for NVIDIA Jetson Platforms - Setting up Yocto - RidgeRun Developer Connection

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.