-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
cv::warpAffine crashes on some image sizes with linear interpolation and CV_8UC4 #19566
Copy link
Copy link
Closed
Labels
bugcategory: imgprocconfirmedThere is stable reproducer / investigation completeThere is stable reproducer / investigation completeoptimizationpriority: normal
Milestone
Description
System information (version)
- OpenCV => 4.5.1
- Operating System / Platform => Linux
- Compiler => gcc / clang
Detailed description
OpenCV crashes (SEGFAULT) when calling cv::warpAffine with some input image sizes like 8192x5464 with linear interpolation.
==23548==ERROR: AddressSanitizer: SEGV on unknown address 0x7f0855378844 (pc 0x7f087c252ef7 bp 0x6290008ed660 sp 0x7fffa16a7750 T0)
==23548==The signal is caused by a READ memory access.
AddressSanitizer:DEADLYSIGNAL
#0 0x7f087c252ef7 (/usr/lib/libopencv_imgproc.so.4.5+0x228ef7)
#1 0x7f087c241673 (/usr/lib/libopencv_imgproc.so.4.5+0x217673)
#2 0x7f087b303b55 in cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (/usr/lib/libopencv_core.so.4.5+0x282b55)
#3 0x7f087c2573dc in cv::remap(cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&, cv::_InputArray const&, int, int, cv::Scalar_<double> const&) (/usr/lib/libopencv_imgproc.so.4.5+0x22d3dc)
#4 0x7f087c259aa8 (/usr/lib/libopencv_imgproc.so.4.5+0x22faa8)
#5 0x7f087b303674 (/usr/lib/libopencv_core.so.4.5+0x282674)
#6 0x7f0876cae104 (/usr/lib/libtbb.so.2+0x2c104)
#7 0x7f0876cae43b (/usr/lib/libtbb.so.2+0x2c43b)
#8 0x7f0876cabd60 (/usr/lib/libtbb.so.2+0x29d60)
#9 0x7f087b3039ec (/usr/lib/libopencv_core.so.4.5+0x2829ec)
#10 0x7f087b303a62 (/usr/lib/libopencv_core.so.4.5+0x282a62)
#11 0x7f0876ca942f in tbb::interface7::internal::task_arena_base::internal_execute(tbb::interface7::internal::delegate_base&) const (/usr/lib/libtbb.so.2+0x2742f)
#12 0x7f087b303d33 in cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (/usr/lib/libopencv_core.so.4.5+0x282d33)
#13 0x7f087c25be94 in cv::hal::warpAffine(int, unsigned char const*, unsigned long, int, int, unsigned char*, unsigned long, int, int, double const*, int, int, double const*) (/usr/lib/libopencv_imgproc.so.4.5+0x231e94)
#14 0x7f087c25c35f in cv::warpAffine(cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&, cv::Size_<int>, int, int, cv::Scalar_<double> const&) (/usr/lib/libopencv_imgproc.so.4.5+0x23235f)
Steps to reproduce
- call
cv::warpAffineusing inputcv::Matwith parameters: size=8192x5464, type=CV_8UC4and usecv::INTER_LINEAR, - best compile test code with
-fsanitize=address, - repeat many times (crash might not happen at first attempt),
- check for crash and/or check image output results (output image can be garbage).
Source code
#include <opencv2/opencv.hpp>
using namespace cv;
int main()
{
for (;;)
{
const Size imgSize(8192, 5464);
Mat inMat = Mat::zeros(imgSize, CV_8UC4);
Mat outMat = Mat::zeros(imgSize, CV_8UC4);
warpAffine(
inMat,
outMat,
getRotationMatrix2D(Point2f(imgSize.width / 2.0f, imgSize.height / 2.0f), 45.0, 1.0),
imgSize,
INTER_LINEAR,
cv::BORDER_CONSTANT,
cv::Scalar(0.0, 0.0, 0.0, 255.0)
);
}
return 0;
}Possible current results
- garbage image
- crash
Image generated from mat size of 8192x5464:

Expected results
- image is rotated properly
Image generated from mat size of 8000x5000:

Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues,
forum.opencv.org, Stack Overflow, etc and have not found solution - I updated to latest OpenCV version and the issue is still there
- There is reproducer code and related data files: videos, images, onnx, etc
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugcategory: imgprocconfirmedThere is stable reproducer / investigation completeThere is stable reproducer / investigation completeoptimizationpriority: normal