diff --git a/src/common/mmap.c b/src/common/mmap.c index 45bdf7a5d3b..8e6dc012622 100644 --- a/src/common/mmap.c +++ b/src/common/mmap.c @@ -355,7 +355,13 @@ util_range_register(const void *addr, size_t len, const char *path, LOG(3, "addr %p len %zu path %s type %d", addr, len, path, type); /* check if not tracked already */ - ASSERTeq(util_range_find((uintptr_t)addr, len), NULL); + if (util_range_find((uintptr_t)addr, len) != NULL) { + ERR( + "duplicated persistent memory range; presumably unmapped with munmap() instead of pmem_unmap(): addr %p len %zu", + addr, len); + errno = ENOMEM; + return -1; + } struct map_tracker *mt; mt = Malloc(sizeof(struct map_tracker)); diff --git a/src/test/pmem_is_pmem_posix/TEST4 b/src/test/pmem_is_pmem_posix/TEST4 index e33c733a88b..774242ba985 100755 --- a/src/test/pmem_is_pmem_posix/TEST4 +++ b/src/test/pmem_is_pmem_posix/TEST4 @@ -74,7 +74,11 @@ expect_normal_exit ./pmem_is_pmem_posix$EXESUFFIX\ t 0x000000020000 0x10000\ t 0x000000030000 0x10000\ t 0x000000040000 0x10000\ - t 0x000000010000 0x40000 + t 0x000000010000 0x40000\ + a 0x000000030000 0x20000 DEV_DAX\ + a 0x000000020000 0x20000 DEV_DAX\ + t 0x000000030000 0x20000\ + t 0x000000020000 0x20000 check diff --git a/src/test/pmem_is_pmem_posix/out4.log.match b/src/test/pmem_is_pmem_posix/out4.log.match index 1f128d19475..2045fc5cb52 100644 --- a/src/test/pmem_is_pmem_posix/out4.log.match +++ b/src/test/pmem_is_pmem_posix/out4.log.match @@ -25,4 +25,7 @@ addr 0x20000 len 65536 is_pmem 0 addr 0x30000 len 65536 is_pmem 0 addr 0x40000 len 65536 is_pmem 0 addr 0x10000 len 262144 is_pmem 0 +duplicated persistent memory range; presumably unmapped with munmap() instead of pmem_unmap(): addr 0x20000 len 131072 +addr 0x30000 len 131072 is_pmem 1 +addr 0x20000 len 131072 is_pmem 0 pmem_is_pmem_posix/TEST4: DONE diff --git a/src/test/pmem_is_pmem_posix/pmem_is_pmem_posix.c b/src/test/pmem_is_pmem_posix/pmem_is_pmem_posix.c index 1a5c60dd56a..8596fbe5825 100644 --- a/src/test/pmem_is_pmem_posix/pmem_is_pmem_posix.c +++ b/src/test/pmem_is_pmem_posix/pmem_is_pmem_posix.c @@ -81,7 +81,8 @@ main(int argc, char *argv[]) case 'a': ret = util_range_register(addr, len, "", str2type(argv[i + 3])); - UT_ASSERTeq(ret, 0); + if (ret != 0) + UT_OUT("%s", pmem_errormsg()); i += 4; break; case 'r':