Segmentation Fault occurred while setting the nveglglessink state

I want to decode 4 video streams, using nveglglessink, shown above the hdmi output.
Each thread of video decoding pipeline is like this

Appsrc-> h265parse-> omxh265dec-> nvvidconv-> textoverlay-> nveglglessink

The program can be normal decoding and display, but when I need to turn off a video decoding, I would like to use gst_element_set_state (pipeline, GST_STATE_NULL) function to completely close the way to decode the image, restore back to the previous black screen status.

However, by setting the state of the entire pipeline, often decoding is stopped, but the last frame is displayed on the display, not returned to the black screen state.

In order to solve this problem, I first set the state of nveglglessink to NULL, nveglglessink state is set to NULL, the window can disappear. And then set the status of the pipeline.

Gst_element_set_state (obj-> display, GST_STATE_NULL);
       Gst_element_set_state (obj-> pipeline, GST_STATE_NULL);
       Gst_object_unref (GST_OBJECT (obj-> pipeline));

When I need to open this video decode, I’ll recreate the pipeline again.
I was configuring the parameters of nveglglessink link:

display = gst_element_factory_make("nveglglessink","display");
    g_object_set (G_OBJECT (display), "max-lateness", 10000000,  NULL); 
    g_object_set (G_OBJECT (display), "ts-offset", 0,  NULL);    
    g_object_set (G_OBJECT (display), "window-x", params_inside->window_x,  NULL);
    g_object_set (G_OBJECT (display), "window-y", params_inside->window_y,  NULL);    
    g_object_set (G_OBJECT (display), "window-width", params_inside->window_width,  NULL); 
    g_object_set (G_OBJECT (display), "window-height", params_inside->window_height,  NULL);    
    g_object_set (G_OBJECT (display), "force-aspect-ratio", TRUE,  NULL);

However, when I create and destroy the pipeline several times, when I call gst_element_set_state (obj-> display, GST_STATE_NULL), a Segmentation fault occurs.

Use gdb to print segment error messages as follows

X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  4 (X_DestroyWindow)
  Resource id in failed request:  0x400001
  Serial number of failed request:  17
  Current serial number in output stream:  18
NvEglHandle: Unfreed handle upon egl deinit: type=2 refcnt=2
NvEglHandle: Unfreed handle upon egl deinit: type=1 refcnt=1

Thread 7 "core" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f9e4d91e0 (LWP 8051)]
0x0000007f7e99cb50 in _nv018glsi () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-glsi.so.24.2.1
(gdb) bt
#0  0x0000007f7e99cb50 in _nv018glsi () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-glsi.so.24.2.1
#1  0x0000007f695f45d4 in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-eglcore.so.24.2.1
#2  0x0000007f695ddf98 in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-eglcore.so.24.2.1
#3  0x0000007f695de154 in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-eglcore.so.24.2.1
#4  0x0000007f696b1bf0 in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-eglcore.so.24.2.1
#5  0x0000007f696b1e30 in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-eglcore.so.24.2.1
#6  0x0000007f696773c4 in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-eglcore.so.24.2.1
#7  0x0000007f69677728 in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-eglcore.so.24.2.1
#8  0x0000007f69648f18 in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-eglcore.so.24.2.1
#9  0x0000007f6960b5a8 in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-eglcore.so.24.2.1
#10 0x0000007f695df898 in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-eglcore.so.24.2.1
#11 0x0000007f695f1f0c in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-eglcore.so.24.2.1
#12 0x0000007f7c045e20 in ?? () from /usr/lib/aarch64-linux-gnu/tegra-egl/libGLESv2.so.2
#13 0x0000007f7ea4f934 in ?? () from /usr/lib/aarch64-linux-gnu/tegra-egl/libEGL_nvidia.so.0
#14 0x0000007f7eaaa99c in ?? () from /usr/lib/aarch64-linux-gnu/tegra-egl/libEGL_nvidia.so.0
#15 0x0000007f7ea48958 in ?? () from /usr/lib/aarch64-linux-gnu/tegra-egl/libEGL_nvidia.so.0
#16 0x0000007fb7fe0098 in _dl_fini () at dl-fini.c:235
#17 0x0000007fb78b2ed8 in __run_exit_handlers (status=1, listp=0x7fb79bf4d8 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true) at exit.c:82
#18 0x0000007fb78b2f00 in __GI_exit (status=<optimized out>) at exit.c:104
#19 0x0000007f7c328294 in _XDefaultError () from /usr/lib/aarch64-linux-gnu/libX11.so.6
#20 0x0000007f7c3283d4 in _XError () from /usr/lib/aarch64-linux-gnu/libX11.so.6
#21 0x0000007f7c3251d4 in ?? () from /usr/lib/aarch64-linux-gnu/libX11.so.6
#22 0x0000007f98336ba0 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

(gdb) bt full
#0  0x0000007f7e99cb50 in _nv018glsi () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-glsi.so.24.2.1
No symbol table info available.
#1  0x0000007f695f45d4 in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-eglcore.so.24.2.1
No symbol table info available.
#2  0x0000007f695ddf98 in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-eglcore.so.24.2.1
No symbol table info available.
#3  0x0000007f695de154 in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-eglcore.so.24.2.1
No symbol table info available.
#4  0x0000007f696b1bf0 in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-eglcore.so.24.2.1
No symbol table info available.
#5  0x0000007f696b1e30 in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-eglcore.so.24.2.1
No symbol table info available.
#6  0x0000007f696773c4 in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-eglcore.so.24.2.1
No symbol table info available.
#7  0x0000007f69677728 in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-eglcore.so.24.2.1
No symbol table info available.
#8  0x0000007f69648f18 in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-eglcore.so.24.2.1
No symbol table info available.
#9  0x0000007f6960b5a8 in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-eglcore.so.24.2.1
No symbol table info available.
#10 0x0000007f695df898 in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-eglcore.so.24.2.1
No symbol table info available.
#11 0x0000007f695f1f0c in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvidia-eglcore.so.24.2.1
No symbol table info available.
#12 0x0000007f7c045e20 in ?? () from /usr/lib/aarch64-linux-gnu/tegra-egl/libGLESv2.so.2
No symbol table info available.
#13 0x0000007f7ea4f934 in ?? () from /usr/lib/aarch64-linux-gnu/tegra-egl/libEGL_nvidia.so.0
No symbol table info available.
#14 0x0000007f7eaaa99c in ?? () from /usr/lib/aarch64-linux-gnu/tegra-egl/libEGL_nvidia.so.0
No symbol table info available.
#15 0x0000007f7ea48958 in ?? () from /usr/lib/aarch64-linux-gnu/tegra-egl/libEGL_nvidia.so.0
No symbol table info available.
#16 0x0000007fb7fe0098 in _dl_fini () at dl-fini.c:235
        array = 0x7f7eb08008
        i = 1
        l = 0x7f981f6db0
        maps = 0x7f9e4d80c0
        i = 15
        l = <optimized out>
        nmaps = 89
        nloaded = <optimized out>
        ns = 0
        do_audit = 127
        __PRETTY_FUNCTION__ = "_dl_fini"
#17 0x0000007fb78b2ed8 in __run_exit_handlers (status=1, listp=0x7fb79bf4d8 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true) at exit.c:82
        atfct = <optimized out>
        onfct = <optimized out>
        cxafct = <optimized out>
#18 0x0000007fb78b2f00 in __GI_exit (status=<optimized out>) at exit.c:104
No locals.
#19 0x0000007f7c328294 in _XDefaultError () from /usr/lib/aarch64-linux-gnu/libX11.so.6
No symbol table info available.
#20 0x0000007f7c3283d4 in _XError () from /usr/lib/aarch64-linux-gnu/libX11.so.6
No symbol table info available.
#21 0x0000007f7c3251d4 in ?? () from /usr/lib/aarch64-linux-gnu/libX11.so.6
No symbol table info available.
#22 0x0000007f98336ba0 in ?? ()
No symbol table info available.
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

Excuse me, is my method of using it incorrect? Or plug-in problem.
This question bothers me for days, please help me, thank you!

Hi Li Lin,
Does it help by calling PLAY → PAUSED → READY → NULL ?

hi,DaneLLL,

Thanks for your advice. I’ll try it for a while.

I found that the error occurred in the case of manually starting Xorg.
If you use the ubuntu desktop system, the status of the pipeline set to NULL, it is possible to automatically close the window.

I manually start the Xorg method is
1, sudo chmod -x / usr / sbin / lightdm
2, use the command Xorg-s 0 &

So manually start X, and enter the desktop system automatically start X, what is the difference?

Hi Li Lin,
Please check the source code of nveglglessink:
[url]https://devtalk.nvidia.com/default/topic/978343/jetson-tx1/nveglglessink-source-code/post/5026985/#5026985[/url]

Hi,

I have the same problem although I didn’t start X manually. I have created a small python test program with a pipeline consisting just of videotestsrc and nveglglessink (version 1.2.3, source release date 2014-02-08) and using the default settings of both elements.
So my pipeline looks like this:

videotestsrc -> nveglglessink

I tried to start and stop the same pipeline twice by setting the pipeline state to PLAYING and NULL. The first run did work but when trying to start the second run I got a segmentation fault when setting the pipeline state to playing again. I also tried to stop the pipeline by setting the pipeline states from PLAYING over PAUSED and READY to NULL and then starting the pipeline again by setting the pipeline from NULL over READY, PAUSED to PLAYING. Then I got the segmentation fault when setting the pipeline state from NULL to READY.

When using xvimagesink instead of nveglglessink restarting the pipeline works fine.

How can I restart the pipeline without recreating it?

Hi Philip,
Please check if below post helps your case:
[url]https://devtalk.nvidia.com/default/topic/1039430/jetson-tk1/x11-window-resizing-problem-with-nveglglessink-plugin/post/5281544/#5281544[/url]