-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Stack use after scope error with BufferArea #22291
Copy link
Copy link
Closed
Labels
Milestone
Description
System information (version)
- OpenCV => 4.6.0
Detailed description
When running with the clang address sanitizer, the following error appears: https://github.com/google/sanitizers/wiki/AddressSanitizerUseAfterScope.
For example, if we take the resizeNN_bitexact function
opencv/modules/imgproc/src/resize.cpp
Line 1211 in 47f30a0
| area.allocate(x_ofse, dsize.width, CV_SIMD_WIDTH); |
BufferArea, the BufferArea area stores a given a pointer to a pointer (x_ofse). In the BufferArea destructor, that pointer to pointer is used to reset the pointer at opencv/modules/core/src/buffer_area.cpp
Line 33 in 47f30a0
| *ptr = 0; |
x_ofse is out of scope.
A solution could be to use a unique_ptr (but that would not work for 3.4) or call the deallocate function by hand before letting the destructor do its job. Please let me know if you see a simpler solution.
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 any solution - I updated to the latest OpenCV version and the issue is still there
Reactions are currently unavailable