mdbx: fixed AddressSanitizer errors after closing db.

Unpoison memory before unmapping, to avoid leaving dangling poisoned
address space. This caused Clang AddressSanitizer false errors after
database was closed.

More for https://github.com/erthink/libmdbx/issues/73

Close https://github.com/erthink/libmdbx/pull/93

Change-Id: I9cf19a06521330a90a62ed15317e1f966f0bd56f
This commit is contained in:
Jens Alfke 2020-04-10 10:23:43 -07:00 committed by Leonid Yuriev
parent 1b451cce06
commit f414876e99

View File

@ -1389,7 +1389,10 @@ MDBX_INTERNAL_FUNC int mdbx_mmap(const int flags, mdbx_mmap_t *map,
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);
/* Unpoisoning is required for ASAN to avoid false-positive diagnostic
* when this memory will re-used by malloc or another mmaping.
* See https://github.com/erthink/libmdbx/pull/93#issuecomment-613687203 */
ASAN_UNPOISON_MEMORY_REGION(map->address, map->limit);
#if defined(_WIN32) || defined(_WIN64)
if (map->section)
NtClose(map->section);