nvjpeg failures with R32.3.1

My test pipeline is

gst-launch-1.0 videotestsrc ! nvjpegenc ! nvjpegdec ! nvoverlaysink

On stock R32.3.1 this runs with a CPU load of 17.8%.
However it slowly leaks memory, a few kilobytes per minute.

I tried the patched library from https://devtalk.nvidia.com/default/topic/1069296/jetson-nano/streaming-using-jpegenc-halts-after-a-short-delay/post/5419826/#5419826

The above pipeline now fails

gst-launch-1.0 videotestsrc ! nvjpegenc ! nvjpegdec ! nvoverlaysink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
NvMapMemHandleCreate: error 22
Pipeline is PREROLLED ...
NvxBaseWorkerFunction[2575] comp OMX.Nvidia.std.iv_renderer.overlay.yuv420 Error -2147479552
Setting pipeline to PLAYING ...
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0:
streaming stopped, reason error (-5)
Execution ended after 0:00:00.000497747
Setting pipeline to PAUSED ...
NvxBaseWorkerFunction[2575] comp OMX.Nvidia.std.iv_renderer.overlay.yuv420 Error -2147479552
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

As does a pipeline with NVMM specified.
This is odd given that videotestsrc is the only non Nvidia plugin.

gst-launch-1.0 videotestsrc ! nvjpegenc ! nvjpegdec ! 'video/x-raw(memory:NVMM)' ! nvoverlaysink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
NvMapMemHandleCreate: error 22
Pipeline is PREROLLED ...
NvxBaseWorkerFunction[2575] comp OMX.Nvidia.std.iv_renderer.overlay.yuv420 Error -2147479552
Setting pipeline to PLAYING ...
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0:
streaming stopped, reason error (-5)
Execution ended after 0:00:00.000431382
Setting pipeline to PAUSED ...
NvxBaseWorkerFunction[2575] comp OMX.Nvidia.std.iv_renderer.overlay.yuv420 Error -2147479552
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

This pipeline still slowly leaks memory and has increased CPU load at 23.7%

gst-launch-1.0 videotestsrc ! nvjpegenc ! nvjpegdec ! video/x-raw ! nvoverlaysink

Attempting to convert videotestsrc fails with sigsegv

gst-launch-1.0 videotestsrc ! nvvidconv ! nvjpegenc ! nvjpegdec  ! nvoverlaysink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Caught SIGSEGV
#0  0x0000007f98125048 in __GI___poll (fds=0x5574a53550, nfds=548013286000, timeout=<optimized out>) at ../sysdeps/unix/sysv/linux/poll.c:41
#1  0x0000007f98231e40 in  () at /usr/lib/aarch64-linux-gnu/libglib-2.0.so.0
#2  0x0000005574926330 in  ()
Spinning.  Please run 'gdb gst-launch-1.0 13303' to continue debugging, Ctrl-C to quit, or Ctrl-\ to dump core.

My original post was
https://devtalk.nvidia.com/default/topic/1066646/jetson-tx2/tx2-sigsegv-with-patched-libnvjpeg-so/post/5427488/

Hi,
For running

... ! nvjpegdec ! 'video/x-raw(memory:NVMM)' ! nvoverlaysink

Please apply this patch and rebuild/replace libgstnvjpeg.so

This pipeline does not leak

gst-launch-1.0 videotestsrc ! nvjpegenc ! nvv4l2decoder mjpeg=true ! nvoverlaysink

I have not yet had time to try the above patch.