SigSegv at NvBufSurfaceDestroy

Hello,
I always get the error message nvbuf_utils:

dmabuf_fd -1853180096 mapped entry NOT found
Caught SIGSEGV

When I try to free a std::vector<std::vector<NvBufSurface*>>called buffer in a loop over each element.
Something like this:

for(int i=0; i<x; i++){
  for(int j=0; j<y; j++){
    NvBufSurfaceDestroy(buffer.at(i).at(j))
  }
}

x and y are the same for the creation of the NvBufSurface.

Any ideas on why this might be happening.
Thanks.

Hi,
The dmabuf fd looks invalid. Do you call NvBufSurfaceCreate() to create the buffer? Or how the buffer is created?

1 Like

Hi @DaneLLL ,
Yes it is created using NvBufSurfaceCreate followed by NvBufSurfaceMemSet.
The NvBufSurfaceCreate is called with the following parameter:

  params.gpuId = DEFAULT_GPU_ID;
  params.memType = NVBUF_MEM_SURFACE_ARRAY;
  params.isContiguous = false;
  params.width = width;
  params.height = height;
  params.size = 0;
  params.layout = NVBUF_LAYOUT_PITCH;
  params.colorFormat = NVBUF_COLOR_FORMAT_NV12;

Because I allocate upt to 100 NvBufSurfaces I checked my Ram, but this seems to be fine. Is there an artifical limit on how much NvBufSurfaces you can have?

Hi,
If you can create the buffer successfully, should be able to destroy it. Could you print out buffer.at(i).at(j) for a check? To make sure the fd is valid before calling NvBufSurfaceDestroy().

1 Like

Hi @DaneLLL
The output is:

                                                                                                     
Vector of vectors                                                                                                     
ptr: 0                                                                                                                
ptr: 5ec0bfa0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c180                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c520                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c1d0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c260                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0c2f0                 

But now I am wondering,
my function for allocating NvBufSurface is this:

void AllocateNvBufSurface(NvBufSurface **surface, int width, int height, NvBufSurfaceLayout layout) noexcept {
  NvBufSurfaceCreateParams params;
  if (*surface != nullptr) {
    NvBufSurfaceDestroy(*surface);
    *surface = nullptr;
  }
  params.gpuId = DEFAULT_GPU_ID;
  params.memType = NVBUF_MEM_SURFACE_ARRAY;
  params.isContiguous = false;
  params.width = width;
  params.height = height;
  params.size = 0;
  params.layout = layout;
  params.colorFormat = NVBUF_COLOR_FORMAT_NV12;
  g_print("ptr: %x\n", *surface);
  CHECK_NVBUFSURFACE_STATUS(NvBufSurfaceCreate(surface, 1, &params), "Error: Could not allocate internal buffer for NvBufSurface at Startup");
  g_print("ptr: %x\n", *surface);
  CHECK_NVBUFSURFACE_STATUS(NvBufSurfaceMemSet(*surface, 0, 0, 0), "Error: Can't set all values of NvBufSurface at startup to 0");
}

And I get

ptr: 0                                                                                                                
ptr: 5ebe0c40                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0acc0                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0b300                                                                                                         
ptr: 0                                                                                                                
ptr: 5ec0b940     

Even for the surfaces I allocate separately and deallocate with NvBufSurfaceDestroy and that works without a problem.

Hi,
Is it possible the vectors are corrupted? Not sure if it is an issue but 5ec0c2f0 is read out for multiple times.

1 Like

Hi @DaneLLL ,
I wouldn’t know how. So far I am only allocating and deallocating it and I don’t use it for anything yet.

@DaneLLL ,
It seems that I found the error. Within the allocation loop I create a structure that contains the NvBufSurface and some other variables. I create this on stack and push it back to the vector. It seems I exceeded the stack size. I now remodeled it with the creation of these structures on the heap and it doesn’t fail anymore.
Thanks for helping again.

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