Conversation
|
It should be enabled by default. |
|
There is severe issue in glibc which affects image processing use cases: repeated allocation/deallocation of several large aligned buffers interleaved with smaller allocations cause memory exhaust. See other examples in the related issue. I think we should disable it by default and enable only for dynamic analysis. Reproducer from the issue attachments: |
|
For correct dynamic analysis results with custom alignment we can leverage manual poisoning in ASAN and special macros for valgrind. |
55bb3bf to
aecfe1e
Compare
aecfe1e to
59efaf2
Compare
CMakeLists.txt
Outdated
| CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H) | ||
| if(HAVE_MALLOC_H) | ||
| CHECK_SYMBOL_EXISTS(memalign malloc.h HAVE_MEMALIGN) | ||
| if(ENABLE_ALIGNED_MALLOC) |
There was a problem hiding this comment.
Parameter name mismatch with OCV_OPTION().
modules/core/src/alloc.cpp
Outdated
| } | ||
|
|
||
| #if defined HAVE_POSIX_MEMALIGN || defined HAVE_MEMALIGN | ||
| static const bool useMemalign = cv::utils::getConfigurationParameterBool("OPENCV_ENABLE_MEMALIGN", false); |
There was a problem hiding this comment.
We should avoid "initialization order fiasco".
Variable can be used below without proper initialization and then crash in mismatched fastFree() calls.
1770c7a to
c405e77
Compare

resolves #15526
This pullrequest changes
Do not use posix_memalign due to possible problems with memory fragmentation in glibc.
Build CMake's option:
OPENCV_ENABLE_MEMALIGN- enabled by default on *NIXRuntime environment parameter:
OPENCV_ENABLE_MEMALIGN- disabled by default (Linux + glibc)valgrind, ASAN and other sanitizers runs must have
OPENCV_ENABLE_MEMALIGN=1for reliable results.