mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-02 02:44:14 +08:00
mdbx: fix ASAN issues (minor).
This resolves https://github.com/leo-yuriev/libmdbx/issues/73 Change-Id: Ifb59f5ba66321bb362b81085e0f25a82a2d76d5f
This commit is contained in:
parent
b3a5ab692b
commit
8c7cdfdc79
@ -4883,7 +4883,7 @@ static void mdbx_txn_valgrind(MDBX_env *env, MDBX_txn *txn) {
|
||||
mdbx_txn_unlock(env);
|
||||
}
|
||||
}
|
||||
#endif /* MDBX_USE_VALGRIND */
|
||||
#endif /* MDBX_USE_VALGRIND || __SANITIZE_ADDRESS__ */
|
||||
|
||||
/* Common code for mdbx_txn_begin() and mdbx_txn_renew(). */
|
||||
static int mdbx_txn_renew0(MDBX_txn *txn, unsigned flags) {
|
||||
@ -7464,7 +7464,7 @@ static int mdbx_sync_locked(MDBX_env *env, unsigned flags,
|
||||
ASAN_POISON_MEMORY_REGION(env->me_map + pgno2bytes(env, largest_pgno),
|
||||
pgno2bytes(env, edge - largest_pgno));
|
||||
}
|
||||
#endif /* MDBX_USE_VALGRIND */
|
||||
#endif /* MDBX_USE_VALGRIND || __SANITIZE_ADDRESS__ */
|
||||
#if defined(MADV_DONTNEED)
|
||||
const size_t largest_bytes = pgno2bytes(env, largest_pgno);
|
||||
const size_t madvise_gap = (largest_bytes < 65536 * 256)
|
||||
@ -8420,7 +8420,7 @@ static int __cold mdbx_setup_dxb(MDBX_env *env, const int lck_rc) {
|
||||
ASAN_POISON_MEMORY_REGION(env->me_map + used_bytes,
|
||||
env->me_dxb_mmap.limit - used_bytes);
|
||||
env->me_poison_edge = bytes2pgno(env, env->me_dxb_mmap.limit);
|
||||
#endif /* MDBX_USE_VALGRIND */
|
||||
#endif /* MDBX_USE_VALGRIND || __SANITIZE_ADDRESS__ */
|
||||
|
||||
/* NOTE: AddressSanitizer (at least GCC 7.x, 8.x) could generate
|
||||
* false-positive alarm here. I have no other explanation for this
|
||||
@ -9213,6 +9213,9 @@ int __cold mdbx_env_open(MDBX_env *env, const char *pathname, unsigned flags,
|
||||
#endif
|
||||
|
||||
bailout:
|
||||
#if defined(MDBX_USE_VALGRIND) || defined(__SANITIZE_ADDRESS__)
|
||||
mdbx_txn_valgrind(env, nullptr);
|
||||
#endif
|
||||
if (rc) {
|
||||
rc = mdbx_env_close0(env) ? MDBX_PANIC : rc;
|
||||
env->me_flags = saved_me_flags | MDBX_FATAL_ERROR;
|
||||
|
@ -949,7 +949,7 @@ struct MDBX_env {
|
||||
#endif
|
||||
#if defined(MDBX_USE_VALGRIND) || defined(__SANITIZE_ADDRESS__)
|
||||
pgno_t me_poison_edge;
|
||||
#endif
|
||||
#endif /* MDBX_USE_VALGRIND || __SANITIZE_ADDRESS__ */
|
||||
MDBX_env *me_lcklist_next;
|
||||
|
||||
/* struct me_dbgeo used for accepting db-geo params from user for the new
|
||||
|
@ -1378,10 +1378,14 @@ MDBX_INTERNAL_FUNC int mdbx_mmap(const int flags, mdbx_mmap_t *map,
|
||||
|
||||
#endif
|
||||
|
||||
VALGRIND_MAKE_MEM_DEFINED(map->address, map->current);
|
||||
ASAN_UNPOISON_MEMORY_REGION(map->address, map->current);
|
||||
return MDBX_SUCCESS;
|
||||
}
|
||||
|
||||
MDBX_INTERNAL_FUNC int mdbx_munmap(mdbx_mmap_t *map) {
|
||||
VALGRIND_MAKE_MEM_NOACCESS(map->address, map->current);
|
||||
ASAN_POISON_MEMORY_REGION(map->address, map->current);
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
if (map->section)
|
||||
NtClose(map->section);
|
||||
|
Loading…
x
Reference in New Issue
Block a user