Repository: opencv
Issue: SegFault error in libopencv_imgproc.so when using cv::cvtColor from OpenCV 4.5.5 (C++) in RHEL 8.5
Labels: bug,category: imgproc,incomplete,needs reproducer

<!--
If you have a question rather than reporting a bug please go to https://forum.opencv.org where you get much faster responses.
If you need further assistance please read [How To Contribute](https://github.com/opencv/opencv/wiki/How_to_contribute).

This is a template helping you to create an issue which can be processed as quickly as possible. This is the bug reporting section for the OpenCV library.
-->

##### System information (version)
<!-- Example
- OpenCV => 4.5.5
- Operating System / Platform => RHEL 8.5 64 Bit
- Compiler => GCC, C++
-->

- OpenCV => 4.5.5
- Operating System / Platform => RHEL v8.5 64 Bit
- Compiler => GCC v11.2 (C++)

##### Detailed description

```.cpp
    cv::cvtColor(bgrImage, yuvImage, cv::COLOR_BGR2YUV_I420);
```

I'm trying to convert BGR image to YUV format using cv::cvtColor from OpenCV 4.5.5 (C++). It works fine in RHEL 7, but when I tried the same code in RHEL 8, the binary is crashing without any error. 

When I checked /var/log/messages, I found the following logs.  
```
Feb  9 08:58:13 ip-172-1-8-2 kernel: test-binary[74520]: segfault at 147f842c3060 ip 0000147f8ad80dcb sp 0000147f891463d8 error 4 in libopencv_imgproc.so.4.5.5[147f8a93f000+5cc000]
Feb  9 08:58:13 ip-172-1-8-2 kernel: Code: 12 00 c5 f5 62 e3 c5 f5 6a cb c4 e3 7d 46 dc 20 c4 e3 7d 46 c4 31 c4 e3 6d 46 e1 20 c4 e3 6d 46 d1 31 c5 e5 62 e8 c5 e5 6a c0 <c5> fa 6f 59 60 c5 dd 62 ca c5 fa 6f 11 c5 fd 7f 44 24 48 c4 e3 6d
Feb  9 08:58:13 ip-172-1-8-2 kernel: test-binary[74532]: segfault at 147f842f5480 ip 0000147f8ad80d40 sp 0000147f838349f8 error 4 in libopencv_imgproc.so.4.5.5[147f8a93f000+5cc000]
Feb  9 08:58:13 ip-172-1-8-2 kernel: Code: 84 8d 01 00 00 48 83 c2 20 41 39 d0 0f 8e 88 04 00 00 83 fe 04 0f 85 af fa ff ff 44 8d 24 d5 00 00 00 00 4d 63 e4 4a 8d 0c 20 <c5> fa 6f 09 c5 fa 6f 41 20 c4 e3 75 38 51 10 01 c4 e3 7d 38 61 30
Feb  9 08:58:13 ip-172-1-8-2 systemd[1]: Started Process Core Dump (PID 74537/UID 0).
Feb  9 08:58:13 ip-172-1-8-2 systemd-coredump[74538]: Resource limits disable core dumping for process 73916 (test-binary).
Feb  9 08:58:13 ip-172-1-8-2 systemd-coredump[74538]: Process 73916 (test-binary) of user 1001 dumped core.
Feb  9 08:58:13 ip-172-1-8-2 systemd[1]: systemd-coredump@12-74537-0.service: Succeeded.
```
Can someone help me in understanding what could be causing this issue? and How to fix it?

Thanks. 

<!-- 
##### Steps to reproduce

to add code example fence it with triple backticks and optional file extension
    ```.cpp
    // C++ code example
    ```
 or attach as .txt or .zip file
-->

##### Issue submission checklist

 - [x] I report the issue, it's not a question
   <!--
   OpenCV team works with forum.opencv.org, Stack Overflow and other communities
   to discuss problems. Tickets with questions without a real issue statement will be
   closed.
   -->
 - [x] I checked the problem with documentation, FAQ, open issues,
       forum.opencv.org, Stack Overflow, etc and have not found any solution
   <!--
   Places to check:
   * OpenCV documentation: https://docs.opencv.org
   * FAQ page: https://github.com/opencv/opencv/wiki/FAQ
   * OpenCV forum: https://forum.opencv.org
   * OpenCV issue tracker: https://github.com/opencv/opencv/issues?q=is%3Aissue
   * Stack Overflow branch: https://stackoverflow.com/questions/tagged/opencv
   -->
 - [x] I updated to the latest OpenCV version and the issue is still there
   <!--
   master branch for OpenCV 4.x and 3.4 branch for OpenCV 3.x releases.
   OpenCV team supports only the latest release for each branch.
   The ticket is closed if the problem is not reproduced with the modern version.
   -->
 - [ ] There is reproducer code and related data files: videos, images, onnx, etc
   <!--
   The best reproducer -- test case for OpenCV that we can add to the library.
   Recommendations for media files and binary files:
   * Try to reproduce the issue with images and videos in opencv_extra repository
     to reduce attachment size
   * Use PNG for images, if you report some CV related bug, but not image reader
     issue
   * Attach the image as an archive to the ticket, if you report some reader issue.
     Image hosting services compress images and it breaks the repro code.
   * Provide ONNX file for some public model or ONNX file with random weights,
     if you report ONNX parsing or handling issue. Architecture details diagram
     from netron tool can be very useful too. See https://lutzroeder.github.io/netron/
   -->