Local memory pool experiment#16421
Merged
opencv-pushbot merged 1 commit intoopencv:3.4from Feb 7, 2020
Merged
Conversation
|
stereoBM throws segfault when the input images are of size approx. 6000 by 9000 pixels. It is caused by overflow of bufSize at the line 1211 Does this patch solves the issue? |
Contributor
Author
|
@dzhura , I think it can solve the issue, especially if safe mode will be used for local buffer. Though we will not know until we try it. Do you have minimal reproducer app? |
There is no segfalut when the number of rows is 8000 or less |
Contributor
Author
|
Your sample does not crash with this patch (on 64-bit system). Valgrind does not show errors too. |
|
Thank you! I look forward to this patch to be merged |
2ea4bb2 to
2edfe30
Compare
d27a2dd to
4cdc163
Compare
alalek
reviewed
Jan 31, 2020
10fcb64 to
83a8121
Compare
New class BufferArea is used to hide complexity of buffers allocations and allow instrumentation with valgrind and sanitizers.
83a8121 to
55cdeaa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pullrequest changes
Introduces
cv::util::BufferAreaclass automating creation of structured memory areas for local memory buffers.There are two modes: safe and unsafe. In safe mode each allocation is performed immediately, in unsafe mode (default) single large buffer will be allocated during the call to commit and all pointers will be set to appropriate locations inside this buffer. Safe mode can be forced at runtime by constructor parameter for one specific object or using an environment variable for all objects (
OPENCV_BUFFER_AREA_ALWAYS_SAFE). Safe mode will also be forced for sanitizer-enabled builds.Single buffer split into several smaller ones is used in several algorithms to reduce memory allocations for better performance. However this approach does not allow to catch OOB access using valgrind or address sanitizer and is prone to errors in address arithmetic calculations. Proposed class allows fast but unsafe mode by default and slower but safer mode for instrumentation and debugging.
Example of use:
Example of old code doing the same work :
This pull request also proposes refactoring of StereoBM algorithm using introduced class. Note: buffers aligning to 64 bytes has been disabled during refactoring.
TODO list: