Merge pull request #11830 from zlobober/fix_mmap_threshold

Move MMAP_THRESHOLD definition to .cpp file.
This commit is contained in:
alexey-milovidov 2020-06-21 14:07:07 +03:00 committed by GitHub
commit e6ab9b969e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 10 deletions

19
src/Common/Allocator.cpp Normal file
View File

@ -0,0 +1,19 @@
#include "Allocator.h"
/** Keep definition of this constant in cpp file; otherwise its value
* is inlined into allocator code making it impossible to override it
* in third-party code.
*
* Note: extern may seem redundant, but is actually needed due to bug in GCC.
* See also: https://gcc.gnu.org/legacy-ml/gcc-help/2017-12/msg00021.html
*/
#ifdef NDEBUG
__attribute__((__weak__)) extern const size_t MMAP_THRESHOLD = 64 * (1ULL << 20);
#else
/**
* In debug build, use small mmap threshold to reproduce more memory
* stomping bugs. Along with ASLR it will hopefully detect more issues than
* ASan. The program may fail due to the limit on number of memory mappings.
*/
__attribute__((__weak__)) extern const size_t MMAP_THRESHOLD = 4096;
#endif

View File

@ -57,16 +57,7 @@
* third-party applications which may already use own allocator doing mmaps * third-party applications which may already use own allocator doing mmaps
* in the implementation of alloc/realloc. * in the implementation of alloc/realloc.
*/ */
#ifdef NDEBUG extern const size_t MMAP_THRESHOLD;
__attribute__((__weak__)) extern const size_t MMAP_THRESHOLD = 64 * (1ULL << 20);
#else
/**
* In debug build, use small mmap threshold to reproduce more memory
* stomping bugs. Along with ASLR it will hopefully detect more issues than
* ASan. The program may fail due to the limit on number of memory mappings.
*/
__attribute__((__weak__)) extern const size_t MMAP_THRESHOLD = 4096;
#endif
static constexpr size_t MMAP_MIN_ALIGNMENT = 4096; static constexpr size_t MMAP_MIN_ALIGNMENT = 4096;
static constexpr size_t MALLOC_MIN_ALIGNMENT = 8; static constexpr size_t MALLOC_MIN_ALIGNMENT = 8;

View File

@ -23,6 +23,7 @@ INCLUDE(${ARCADIA_ROOT}/clickhouse/cmake/yandex/ya.make.versions.inc)
SRCS( SRCS(
ActionLock.cpp ActionLock.cpp
AlignedBuffer.cpp AlignedBuffer.cpp
Allocator.cpp
checkStackSize.cpp checkStackSize.cpp
ClickHouseRevision.cpp ClickHouseRevision.cpp
Config/AbstractConfigurationComparison.cpp Config/AbstractConfigurationComparison.cpp