NvSIPBuffer doesn't implement a virtual destructor

Please provide the following info:
Hardware Platform: DRIVE AGX Xavier™ Developer Kit
Software Version: DRIVE Software 10
Host Machine Version: native Ubuntu 18.04
SDK Manager Version: 1.0.1.5538

Hi all,

I found that NvSIPBuffer doesn’t implement a virtual destructor and I am concerned if this could generate a memory leak.

I tried to add the virtual destructor but I got a segfault because I need to regenerated the libnvsipl.so but I don’t have that code.

Are there plans to fix this in the next releases?

Regards,
Mauricio

Dear @mauricio.montero,
Could you please share how you figured out about it. Also, please provide a repro code if possible?

Hi SivaRamaKrishnaNV,

I found this by checking the file NvSIPLClient.hpp where I found that the INvSIPLBuffer class has virtual functions but doesn’t add a virtual destructor. This may result in memory leaks if the destructor of the subclass frees resources.

You can reproduce this problem by compiling your ~/nvmedia-samples/samples/nvmedia/nvsipl sample and adding the -Wnon-virtual-dtor compilation flag. You’ll see the following warning:

In file included from CComposite.hpp:20:0,
                 from CComposite.cpp:15:
/usr/include/gstreamer-1.0/gst/nvmedia/NvSIPLClient.hpp:115:11: warning: ‘class nvsipl::INvSIPLClient::INvSIPLBuffer’ has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]
     class INvSIPLBuffer
           ^~~~~~~~~~~~~
/usr/include/gstreamer-1.0/gst/nvmedia/NvSIPLClient.hpp:140:11: warning: base class ‘class nvsipl::INvSIPLClient::INvSIPLBuffer’ has accessible non-virtual destructor [-Wnon-virtual-dtor]
     class INvSIPLNvMBuffer : public INvSIPLBuffer
           ^~~~~~~~~~~~~~~~
/usr/include/gstreamer-1.0/gst/nvmedia/NvSIPLClient.hpp:140:11: warning: ‘class nvsipl::INvSIPLClient::INvSIPLNvMBuffer’ has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]
g++    -DWIN_INTERFACE_CUSTOM -D_POSIX_C_SOURCE=200112L -I. -I../../include -I../../query/include -I../utils/include/ -I/usr/include/gstreamer-1.0/gst/nvmedia/ -I/usr/include/gstreamer-1.0/gst/nvmedia/utils/ -std=c++11 -fexceptions -frtti -fPIC -Wnon-virtual-dtor  -c -o CUtils.o CUtils.cpp
In file included from /usr/include/gstreamer-1.0/gst/nvmedia/NvSIPLPipelineMgr.hpp:15:0,
                 from /usr/include/gstreamer-1.0/gst/nvmedia/NvSIPLCamera.hpp:15,
                 from CUtils.cpp:18:
/usr/include/gstreamer-1.0/gst/nvmedia/NvSIPLClient.hpp:115:11: warning: ‘class nvsipl::INvSIPLClient::INvSIPLBuffer’ has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]
     class INvSIPLBuffer
           ^~~~~~~~~~~~~
/usr/include/gstreamer-1.0/gst/nvmedia/NvSIPLClient.hpp:140:11: warning: base class ‘class nvsipl::INvSIPLClient::INvSIPLBuffer’ has accessible non-virtual destructor [-Wnon-virtual-dtor]
     class INvSIPLNvMBuffer : public INvSIPLBuffer
           ^~~~~~~~~~~~~~~~
/usr/include/gstreamer-1.0/gst/nvmedia/NvSIPLClient.hpp:140:11: warning: ‘class nvsipl::INvSIPLClient::INvSIPLNvMBuffer’ has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]
g++    -DWIN_INTERFACE_CUSTOM -D_POSIX_C_SOURCE=200112L -I. -I../../include -I../../query/include -I../utils/include/ -I/usr/include/gstreamer-1.0/gst/nvmedia/ -I/usr/include/gstreamer-1.0/gst/nvmedia/utils/ -std=c++11 -fexceptions -frtti -fPIC -Wnon-virtual-dtor  -c -o main.o main.cpp
In file included from /usr/include/gstreamer-1.0/gst/nvmedia/NvSIPLPipelineMgr.hpp:15:0,
                 from /usr/include/gstreamer-1.0/gst/nvmedia/NvSIPLCamera.hpp:15,
                 from main.cpp:28:
/usr/include/gstreamer-1.0/gst/nvmedia/NvSIPLClient.hpp:115:11: warning: ‘class nvsipl::INvSIPLClient::INvSIPLBuffer’ has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]
     class INvSIPLBuffer
           ^~~~~~~~~~~~~
/usr/include/gstreamer-1.0/gst/nvmedia/NvSIPLClient.hpp:140:11: warning: base class ‘class nvsipl::INvSIPLClient::INvSIPLBuffer’ has accessible non-virtual destructor [-Wnon-virtual-dtor]
     class INvSIPLNvMBuffer : public INvSIPLBuffer
           ^~~~~~~~~~~~~~~~
/usr/include/gstreamer-1.0/gst/nvmedia/NvSIPLClient.hpp:140:11: warning: ‘class nvsipl::INvSIPLClient::INvSIPLNvMBuffer’ has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]
cc    -L/usr/lib/aarch64-linux-gnu/ -o nvsipl_camera CComposite.o CUtils.o main.o -L../../lib -lnvsipl_query -lnvsipl -lnvmedia -L../utils/lib/ -lpthread -ldl -lrt -lstdc++

I cannot simply add a virtual destructor to the header because the provided libnvsipl.so library depends on it. Adding it results in a segfault. The library needs to be recompiled with the fixed header.

Regards,
Mauricio M.

Dear @mauricio.montero,
Could you please confirm if you are using DRIVE AGX platform? I don’t see /usr/include/gstreamer-1.0/gst/nvmedia/NvSIPLClient.hpp path on my machine.

Hi SivaRamaKrishnaNV,

Yes, I confirm that I am using the DRIVE AGX platform.

These examples are typically cross-compiled from the host machine. I just installed the headers manually myself to be able to compile them natively. To reproduce the problem following the steps recommended by NVIDIA you may download the Drive 10.0 rev2 with the SDK manager, and go to the examples path and change the makefile of the nvispl example to add the -Wnon-virtual-dtor compilation flag similar to the following:

maumontero@maumontero-Inspiron-5577:~/JetPack-4.4/DRIVE_Software_10.0_Linux_OS_DDPX/DRIVEOS/drive-t186ref-linux/samples/nvmedia/nvsipl/test/camera$ vi Makefile

in this makefile add the flag in the CPPFLAGS like:

CPPFLAGS += -std=c++11 -fexceptions -frtti -fPIC -Wnon-virtual-dtor

after this go to the nvsipl example and run make clean and make like this:

maumontero@maumontero-Inspiron-5577:~/JetPack-4.4/DRIVE_Software_10.0_Linux_OS_DDPX/DRIVEOS/drive-t186ref-linux/samples/nvmedia/nvsipl$ make clean

maumontero@maumontero-Inspiron-5577:~/JetPack-4.4/DRIVE_Software_10.0_Linux_OS_DDPX/DRIVEOS/drive-t186ref-linux/samples/nvmedia/nvsipl$ make

When you run the make command you will get a warning like the following:


In file included from CComposite.hpp:20:0,
                 from CComposite.cpp:15:
/home/maumontero/JetPack-4.4/DRIVE_Software_10.0_Linux_OS_DDPX/DRIVEOS/drive-t186ref-linux/include/NvSIPLClient.hpp:115:11: warning: 'class nvsipl::INvSIPLClient::INvSIPLBuffer' has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]
     class INvSIPLBuffer
           ^~~~~~~~~~~~~
/home/maumontero/JetPack-4.4/DRIVE_Software_10.0_Linux_OS_DDPX/DRIVEOS/drive-t186ref-linux/include/NvSIPLClient.hpp:140:11: warning: base class 'class nvsipl::INvSIPLClient::INvSIPLBuffer' has accessible non-virtual destructor [-Wnon-virtual-dtor]
     class INvSIPLNvMBuffer : public INvSIPLBuffer
           ^~~~~~~~~~~~~~~~
/home/maumontero/JetPack-4.4/DRIVE_Software_10.0_Linux_OS_DDPX/DRIVEOS/drive-t186ref-linux/include/NvSIPLClient.hpp:140:11: warning: 'class nvsipl::INvSIPLClient::INvSIPLNvMBuffer' has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]
"/home/maumontero/JetPack-4.4/DRIVE_Software_10.0_Linux_OS_DDPX/DRIVEOS"/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu//bin/aarch64-linux-gnu-g++  -DWIN_INTERFACE_CUSTOM -DX11 -I"/home/maumontero/JetPack-4.4/DRIVE_Software_10.0_Linux_OS_DDPX/DRIVEOS"/drive-t186ref-linux/include -DWIN_INTERFACE_CUSTOM -D_POSIX_C_SOURCE=200112L -I. -I../../include -I../../query/include -I../utils/include/ -std=c++11 -fexceptions -frtti -fPIC -Wnon-virtual-dtor  -c -o CUtils.o CUtils.cpp
"/home/maumontero/JetPack-4.4/DRIVE_Software_10.0_Linux_OS_DDPX/DRIVEOS"/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu//bin/aarch64-linux-gnu-g++  -DWIN_INTERFACE_CUSTOM -DX11 -I"/home/maumontero/JetPack-4.4/DRIVE_Software_10.0_Linux_OS_DDPX/DRIVEOS"/drive-t186ref-linux/include -DWIN_INTERFACE_CUSTOM -D_POSIX_C_SOURCE=200112L -I. -I../../include -I../../query/include -I../utils/include/ -std=c++11 -fexceptions -frtti -fPIC -Wnon-virtual-dtor  -c -o main.o main.cpp
In file included from /home/maumontero/JetPack-4.4/DRIVE_Software_10.0_Linux_OS_DDPX/DRIVEOS/drive-t186ref-linux/include/NvSIPLPipelineMgr.hpp:15:0,
                 from /home/maumontero/JetPack-4.4/DRIVE_Software_10.0_Linux_OS_DDPX/DRIVEOS/drive-t186ref-linux/include/NvSIPLCamera.hpp:15,
                 from main.cpp:38:
/home/maumontero/JetPack-4.4/DRIVE_Software_10.0_Linux_OS_DDPX/DRIVEOS/drive-t186ref-linux/include/NvSIPLClient.hpp:115:11: warning: 'class nvsipl::INvSIPLClient::INvSIPLBuffer' has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]
     class INvSIPLBuffer
           ^~~~~~~~~~~~~
/home/maumontero/JetPack-4.4/DRIVE_Software_10.0_Linux_OS_DDPX/DRIVEOS/drive-t186ref-linux/include/NvSIPLClient.hpp:140:11: warning: base class 'class nvsipl::INvSIPLClient::INvSIPLBuffer' has accessible non-virtual destructor [-Wnon-virtual-dtor]
     class INvSIPLNvMBuffer : public INvSIPLBuffer
           ^~~~~~~~~~~~~~~~
/home/maumontero/JetPack-4.4/DRIVE_Software_10.0_Linux_OS_DDPX/DRIVEOS/drive-t186ref-linux/include/NvSIPLClient.hpp:140:11: warning: 'class nvsipl::INvSIPLClient::INvSIPLNvMBuffer' has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]

Please let me know if you can replicate this behavior.

Regards,
Mauricio M.