nvbuf_utils: dmabuf_fd 1286 mapped entry NOT found

Hi all,

I am developing a gstreamer application on Jetson TX2 which is supposed to process video coming from a CSI camera.

At one point in my pipeline, I get a segmentation fault and the program crashes with the following message.

According to gdb the crash occurs somewhere here:

The strange thing is that the calling code looks like this:

void fillWorkingBuffer(GstBuffer* gst_buffer, int working_fd) {
    GstMapInfo in_map_info;
    if (gst_buffer_map(gst_buffer, &in_map_info, GST_MAP_READ) == false) {
        SafePrint("Failed to map gstbuffer data for read access", AnsiColor::BLUE);

    int in_dmabuf_fd = -1;
    if (ExtractFdFromNvBuffer(in_map_info.data, &in_dmabuf_fd) != 0) {
        SafePrint("Failed to map hardware buffer on gstbuffer data", AnsiColor::BLUE);

    NvBufferParams params = { };
    if (NvBufferGetParams(in_dmabuf_fd, &params) != 0) {
        SafePrint("Failed to extract buffer params for fd=" + std::to_string(in_dmabuf_fd), AnsiColor::BLUE);

    if (NvBufferComposite(&in_dmabuf_fd, working_fd, &composite_params) != 0) {
        SafePrint("Failed NvBufferComposite from " + std::to_string(in_dmabuf_fd) + " to " + std::to_string(working_fd), AnsiColor::BLUE);

    if (NvReleaseFd(in_dmabuf_fd) != 0) {
        SafePrint("Failed to release Fd=" + std::to_string(in_dmabuf_fd), AnsiColor::BLUE);

    gst_buffer_unmap(gst_buffer, &in_map_info);

So ExtractFdFromNvBuffer has given me the dmabuf_fd of 1286 and returned a success code.
I am able to call NvBufferGetParams without error, yet when NvBufferComposite apparently calls this same function under the hood something goes wrong.

Any idea what could be going wrong here?

Please check the sample code at
For NvBufferComposite(), please refer to tegra_multimedia_api\samples\13_multi_camera

For future readers: the code is correct but as it runs in a multi-threaded context it turns out that another gstreamer plugin (nvosd) further down the pipeline appeared to be concurrently mapping the same hardware buffer ReadWrite mode.

My plugin processes buffers asynchronously. It increases the refcount so they don’t get released before they are processed but concurrently mapping in Write mode is obviously a bad idea. As a current workaround I have just removed the nvosd block but I guess that inserting buffer copy somewhere would also work.