mdbx: fix ASAN-regression after 1740043678951c5a1a088e6572722de438162ab2.

Related to https://github.com/erthink/libmdbx/issues/217
This commit is contained in:
Leonid Yuriev 2021-07-16 15:40:02 +03:00
parent 6034985686
commit d67b9eaf17

View File

@ -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