Getting Segmentation Fault while using Custom Struct as gpointer u_data in analytics_done_buf_prob() in deepsteam_app.c

• Hardware Platform ( GPU: Nvidia GeForce 4090)
• DeepStream Version: 6.2 docker container
• NVIDIA GPU Driver Version: 525.147.05
• Issue Type(bugs)

I added in a custom struct

typedef struct BigCtx {
  NvDsObjEncCtxHandle *enc_ctx;
  NvDsInstanceBin *instance_bin;
} BigCtx;

and sent it to the analytics_done_buf_prob() throughcreate_common_elements in deepstream_app.c like this

NvDsObjEncCtxHandle obj_ctx_handle = nvds_obj_enc_create_context(0);
BigCtx big_ctx;
big_ctx.enc_ctx = &obj_ctx_handle;
big_ctx.instance_bin = &pipeline->common_elements;

NVGSTDS_ELEM_ADD_PROBE (pipeline->common_elements.primary_bbox_buffer_probe_id, 
                            *src_elem, "src",
                            analytics_done_buf_prob, GST_PAD_PROBE_TYPE_BUFFER,
                            (gpointer)&big_ctx);

These are the changes I made in the probe

static GstPadProbeReturn
analytics_done_buf_prob (GstPad * pad, GstPadProbeInfo * info, gpointer u_data)
{
  BigCtx *big_ctx = (BigCtx *) u_data;
  NvDsObjEncCtxHandle *enc_ctx = big_ctx->enc_ctx;
  NvDsInstanceBin *bin = (NvDsInstanceBin *) big_ctx->instance_bin;
  //NvDsInstanceBin *bin = (NvDsInstanceBin *) u_data;
  guint index = bin->index;
  AppCtx *appCtx = bin->appCtx;
  GstBuffer *buf = (GstBuffer *) info->data;
  NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta (buf);
  if (!batch_meta) {
    NVGSTDS_WARN_MSG_V ("Batch meta not found for buffer %p", buf);
    return GST_PAD_PROBE_OK;
  }
  GstMapInfo inmap = GST_MAP_INFO_INIT;
  NvBufSurface *ip_surf = (NvBufSurface *) inmap.data;
  gst_buffer_unmap (buf, &inmap);
...

This is giving me segmentation fault, can you let me know how to solve this issue?

Could you add some logs to make sure which point is NULL?

it’s solved, i had to use reference variables