DS 6.2 - NvBufSurfaceMap - SIGSEGV

I am refering to the issue DS 6.1.1 - NvBufSurfaceMap - SIGSEGV

the problem still occurs when using:

NvBufSurfaceMap (&nvinfer->tmp_surf, -1, -1, NVBUF_MAP_READ)

In the code example used in DS 6.1.1 - NvBufSurfaceMap - SIGSEGV which is based on DeepStream SDK FAQ - #17 by mchi there is no usage of parameters -1, -1 (map all indexes and all planes). The code works only when tmp_surf->batchSize == 1 or tmp_surf->batchSize == nvinfer->tmp_surf.numFilled.

The SIGSEGV occurs in /usr/lib/aarch64-linux-gnu/tegra/libnvbufsurface.so.1.0.0 when tmp_surf->batchSize != nvinfer->tmp_surf.numFilled (the batch is partially filled) and function NvBufSurfaceMap (&nvinfer->tmp_surf, -1, -1, NVBUF_MAP_READ) is called. I have changed my implementation to do per-index surface mapping and it works fine. The bug with parameters -1, -1 used in function NvBufSurfaceMap in combination with partially filled batch occured in DS since version 6.

You mean when the batch is partially filled and use -1,-1 parameters, it will crash? And you fixed it by:

yes, it is ok when I use surface index to map it (iterating to nvinfer->tmp_surf.numFilled):

NvBufSurfaceMap (&nvinfer->tmp_surf, i, -1, NVBUF_MAP_READ)

but it crashes when I try to map the whole batch with -1 parameter and the batch is partially filled.

Could you attach your minimized code to us? We can try to run in our env. You can add your patch to one of our demo code and provide to us.

here is the diff

diff --git a/gstnvinfer.cpp b/gstnvinfer_bug.cpp
index 061234a..ee25637 100644
--- a/gstnvinfer.cpp
+++ b/gstnvinfer_bug.cpp
@@ -1426,6 +1426,36 @@ convert_batch_and_push_to_input_thread (GstNvInfer *nvinfer,
   eventAttrib.message.ascii = nvtx_str.c_str();
 
   nvtxDomainRangePushEx(nvinfer->nvtx_domain, &eventAttrib);
+  
+  printf("batch->frames.size() = %lu\n", batch->frames.size());
+  if (1) {
+    NvBufSurface *tmp_surf = &(nvinfer->tmp_surf);
+
+    printf("nvinfer->tmp_surf: \n");
+    printf("  batchSize = %d\n", tmp_surf->batchSize);
+    printf("  numFilled = %d\n", tmp_surf->numFilled);
+    printf("  memType = %d\n", tmp_surf->memType);
+
+    if (NvBufSurfaceMap (tmp_surf, -1, -1, NVBUF_MAP_READ) != 0)
+      printf("NvBufSurfaceMap failed ===============\n");
+    
+    if(tmp_surf->memType == NVBUF_MEM_SURFACE_ARRAY) {
+      /* Cache the mapped data for CPU access */
+      NvBufSurfaceSyncForCpu (tmp_surf, -1, -1);
+    }
+
+    for (int nf = 0; nf < tmp_surf->numFilled; nf++) {
+      NvBufSurfaceParams *sur = &(tmp_surf->surfaceList[nf]);
+      if (sur == NULL)
+        break;
+
+      // HERE THE IMAGE DATA CAN BE ACCESSED VIA:
+      // nvinfer->tmp_surf.surfaceList[nf]->mappedAddr.addr[0]
+      // nvinfer->tmp_surf.surfaceList[nf]->mappedAddr.addr[1]
+    }
+
+    NvBufSurfaceUnMap (tmp_surf, -1, -1);
+  }
 
   if (batch->frames.size() > 0) {
     /* Batched tranformation. */

the above code works only if tmp_surf->batchSize == tmp_surf->numFilled

in case tmp_surf->batchSize > tmp_surf->numFilled the crash occurs

this can be done by setting bigger batch size (in my case 12) to the gie and setting some batched-push-timeout to nvstreammux so that the batch won’t fill up

There is no update from you for a period, assuming this is not an issue anymore. Hence we are closing this topic. If need further support, please open a new one. Thanks

I cannot repro your problems in my env. Could you attach a minimized demo app and your gstnvinfer.cpp file for this problem?
Also, you can update the DeepStream to the latest version(6.2) and check if the problem still exists.

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