From d67b9eaf17616da8fea1ac628c6a53e03de1878c Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Fri, 16 Jul 2021 15:40:02 +0300 Subject: [PATCH] mdbx: fix ASAN-regression after 1740043678951c5a1a088e6572722de438162ab2. Related to https://github.com/erthink/libmdbx/issues/217 --- src/core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core.c b/src/core.c index e41fc2f0..a6202faa 100644 --- a/src/core.c +++ b/src/core.c @@ -11642,13 +11642,17 @@ __cold static int mdbx_setup_dxb(MDBX_env *env, const int lck_rc, mdbx_assert(env, used_bytes >= pgno2bytes(env, NUM_METAS) && used_bytes <= env->me_dxb_mmap.limit); #if defined(MDBX_USE_VALGRIND) || defined(__SANITIZE_ADDRESS__) - if (env->me_dxb_mmap.filesize > used_bytes) { + if (env->me_dxb_mmap.filesize > used_bytes && + env->me_dxb_mmap.filesize < env->me_dxb_mmap.limit) { VALGRIND_MAKE_MEM_NOACCESS(env->me_map + used_bytes, env->me_dxb_mmap.filesize - used_bytes); MDBX_ASAN_POISON_MEMORY_REGION(env->me_map + used_bytes, env->me_dxb_mmap.filesize - used_bytes); } - env->me_poison_edge = bytes2pgno(env, env->me_dxb_mmap.filesize); + env->me_poison_edge = + bytes2pgno(env, (env->me_dxb_mmap.filesize < env->me_dxb_mmap.limit) + ? env->me_dxb_mmap.filesize + : env->me_dxb_mmap.limit); #endif /* MDBX_USE_VALGRIND || __SANITIZE_ADDRESS__ */ //-------------------------------- validate/rollback head & steady meta-pages