Sending an NvBufSurface across processes failing NvBufSurfTransform (Segfault)

Hello, I am trying to send an NvBufSurface across processes using the recommended approach I found online, which was NvBufSurfaceImport.

Running Jetpack 5.1.4

Source:

I am able to send the MapParams over a socket and the file descriptor using SCM_RIGHTs, and use NvBufSurfaceImport to re-construct the image.

I was able to fill the image up with a known pattern and check in the child/receiver process that the values were correct, meaning that the memory mapping seemed to have worked.

However whenever I try and pass the imported NvBufSurface as the src to NvBufSurfaceTransform, I get a segfault on a memset somewhere. I’m not sure what’s wrong, because I’ve mapped the memory and iterated through it and it seems correct.

GDB Output:

(gdb) break NvBufSurfTransform
warning: could not convert 'NvBufSurfTransform' from the host encoding (ANSI_X3.4-1968) to UTF-32.
This normally should not happen, please file a bug report.
Breakpoint 1 at 0xffff3826237c
(gdb) c
Continuing.

Breakpoint 1, 0x0000ffff3826237c in NvBufSurfTransform () from /usr/lib/libnvbufsurftransform.so.1.0.0
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
__GI___memset_generic () at ../sysdeps/aarch64/memset.S:86
86      ../sysdeps/aarch64/memset.S: No such file or directory.

(gdb) bt                                                                                                                                                                                                                                                                              
#0  __GI___memset_generic () at ../sysdeps/aarch64/memset.S:86                                                                                                                                                                                                                        
#1  0x0000ffff698650bc in ?? () from /usr/lib/libnvvic.so                                                                                                                                                                                                                             
#2  0x0000ffff6986cb28 in ?? () from /usr/lib/libnvvic.so                                                                                                                                                                                                                             
#3  0x0000ffff69862228 in NvVicCompose () from /usr/lib/libnvvic.so                                                                                                                                                                                                                   
#4  0x0000ffff7cb51730 in NvBufSurfTransformAsync () from /usr/lib/libnvbufsurftransform.so.1.0.0                                                                                                                                                                                     
#5  0x0000aaaaaaaa320c in main () at 
test.cpp:515 

Pseudocode:

Provider:

Allocate Surface
Map Surface
Fill with Known Data
Get Params from Surface
Get dmabuf FD from Surface
Send params, FD over socket.

Consumer:

RX Params and FD
params.fd = FD (file descriptor transfered using SCM_RIGHTs)
NvBufSurfaceImport(output_buf, params)
map output buf
check output buf for data

transform output-buf to new nvbufsurface to show that operations on this new imported buffer work (color conversion, crop. etc…)

Actual Code that replicates the issue:

test.cpp.txt (12.0 KB)

Really would appreciate any feedback. Thank you!

Output with DBGNVBUFSURFTRANSFORM=1:

CHILD: Calling NvBufSurfTransform
/dvs/git/dirty/git-master_linux/nvutils/nvbufsurftransform/nvbufsurftransform.cpp:2559: NvBufSurfTransformAsync=> Using default session created 
PARENT: Child process completed with status 11
/dvs/git/dirty/git-master_linux/nvutils/nvbufsurftransform/nvbufsurftransform.cpp:1899: libnvbufsurf_transform_deinit=> Deinit lib
/dvs/git/dirty/git-master_linux/nvutils/nvbufsurftransform/nvbufsurftransform.cpp:1890: NvBufSurfTransformSessionDestroy=> Session destroyed 0xaaab197acfa0
/dvs/git/dirty/git-master_linux/nvutils/nvbufsurftransform/nvbufsurftransform.cpp:985: taskTrim=> Exiting Clean up thread

Hi,
There is demonstration in the sample after Jetpack 5.1.5:

/usr/src/jetson_multimedia_api/samples/13_argus_multi_camera

Please refer to it and try the same on 5.1.4. It is supposed to work as well on 5.1.4.

Thank you for responding.

I will try to find the source code for the app you mentioned, but based on this:

I am not sure it is doing what I am looking for.
Specifically I want to be able to share the NvBufSurface between processes using the method pointed out by you here.

Any chance you can take a look at the C++ snippet I posted and help me understand what I did wrong? I will also compare to the argus sample.

Part of my reasoning to separate out the processes is to isolate one of them from interacting with Argus and just work with buffers/surfaces/etc.

Is this still an issue to support? Any result can be shared?

Hi,

I have resolved the issue.

For the fork example I shared, a new NvBufSurfTransform Session must be created using SetSessionParams. (Because fork keeps the original properties in the children processes)

If spawning an entirely new process without fork it works as intended.

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