I’m working on a GStreamer plugin/element to process NvDsBatchMeta metadata from the DeepStream elements. While the element is working in a pipeline, I’m running into a segmentation fault when writing unit tests for my element. Specifically, I want to generate buffers with some NvDsBatchMeta metadata attached and see if the output is as I expect. The only method I’ve found to attach that metadata is to call gst_buffer_add_nvds_meta. That function takes a copy function and I want to pass nvds_batch_meta_copy_func as the copy function (i.e. the copy_func parameter), but I’m getting a crash when nvds_batch_meta_copy_func is called and the batch meta has a frame meta added to it.
Here’s my code to reproduce the problem, using only nvds_batch_meta_copy_func.
#include <gst/gst.h>
#include <gstnvdsmeta.h>
int main(int argc, char **argv)
{
gst_init(&argc, &argv);
NvDsBatchMeta *batch_meta = nvds_create_batch_meta(2);
NvDsFrameMeta *frame_meta = nvds_acquire_frame_meta_from_pool(batch_meta);
nvds_add_frame_meta_to_batch(batch_meta, frame_meta);
gpointer test_copy = nvds_batch_meta_copy_func(batch_meta, nullptr);
}
In a related post (Deepstream deepcopy metadata) I saw a solution saying to use nvds_copy_frame_meta_list, so I tried again, without success.
#include <gst/gst.h>
#include <gstnvdsmeta.h>
static gpointer
alt_batch_meta_copy_func(gpointer data, gpointer user_data)
{
NvDsBatchMeta *batch_meta = (NvDsBatchMeta *)data;
NvDsBatchMeta *other = nvds_create_batch_meta(batch_meta->max_frames_in_batch);
nvds_copy_frame_meta_list(batch_meta->frame_meta_list, other);
return other;
}
int main(int argc, char **argv)
{
gst_init(&argc, &argv);
NvDsBatchMeta *batch_meta = nvds_create_batch_meta(2);
NvDsFrameMeta *frame_meta = nvds_acquire_frame_meta_from_pool(batch_meta);
nvds_add_frame_meta_to_batch(batch_meta, frame_meta);
gpointer test_copy = alt_batch_meta_copy_func(batch_meta, nullptr);
}
Here’s the back trace from GDB, for the first program.
Program received signal SIGSEGV, Segmentation fault.
0x0000007fb7fa3504 in ?? () from /opt/nvidia/deepstream/deepstream-6.0/lib/libnvds_meta.so
(gdb) bt
#0 0x0000007fb7fa3504 in ?? () from /opt/nvidia/deepstream/deepstream-6.0/lib/libnvds_meta.so
#1 0x0000007fb7fa2a2c in nvds_copy_frame_meta_list () from /opt/nvidia/deepstream/deepstream-6.0/lib/libnvds_meta.so
#2 0x0000007fb7fa2ab4 in ?? () from /opt/nvidia/deepstream/deepstream-6.0/lib/libnvds_meta.so
#3 0x000000555555590c in main (argc=<optimized out>, argv=<optimized out>) at min1.cpp:10
Is there some initialization step that I’m missing? Is there another way to attach the metadata to a GStreamer buffer?
I’m running DeepStream 6.0.1 on a Jetson Nano. The MD5sum of /opt/nvidia/deepstream/deepstream-6.0/lib/libnvds_meta.so is 4c9b0870fd9e2e256a54c04814023c86.