Opencv write clash with the jpeg enc

hi all ,when i test the jpeg enc and the opencv ,i fount that if i use the opencv cv::imwrite and the jpeg enc at the same time ,my programe will crash ,so i want to know why ?

some other situation is that when i integrate,sometimes will have following error:

JPEG parameter struct mismatch: library thinks size is 584, caller expects 728

the opencv lib and the nvjpeg lib all use the system supplyed

Please refer to
Unable to use gstreamer programmaticaly with nvjpegenc and opencv 4.1.1 simultaneously - #3 by DaneLLL