Segmentation fault at rectangle() call

Hello All,
I am facing problem in rectangle function and filter2D while using OpenCV4.6 in C++ on Linux system. OpenCV 4.3 version is working absolutely fine. I have checked all .hpp files are also in place.
Please advice why its happening so

which problem, exactly ?
we are not psychics, please explain, thank you.

segmentation fault is coming and when the control of program reaches at rectangle function it crashes and similarly for filter2D

show code / data, for heaven’s sake !

Point p1(270,415);
Point p2(470,615);
if (check==1)
rectangle(img, p1, p2, Scalar(255,255,255,1));

When it accesses rectangle function from imgproc it crashes

Welcome. MRE required. Thank you.