Skip to content

pmem2: remove data_mover memory leak #5681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/libpmem2/map_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,10 +621,11 @@ pmem2_map_delete(struct pmem2_map **map_ptr)
if (ret)
goto err_register_map;
}

if (!map->custom_vdm)
mover_delete(map->vdm);
}

if (!map->custom_vdm)
mover_delete(map->vdm);

Free(map);
*map_ptr = NULL;

Expand Down
7 changes: 5 additions & 2 deletions src/libpmem2/mover.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2021-2022, Intel Corporation */
/* Copyright 2021-2023, Intel Corporation */

/*
* mover.c -- default pmem2 data mover
Expand All @@ -12,6 +12,7 @@
#include "out.h"
#include "pmem2_utils.h"
#include "util.h"
#include "alloc.h"
#include <inttypes.h>
#include <stdlib.h>
#include <unistd.h>
Expand Down Expand Up @@ -194,6 +195,7 @@ mover_new(struct pmem2_map *map, struct vdm **vdm)
goto membuf_failed;
}

LOG(3, "dms %p", dms);
return 0;

membuf_failed:
Expand All @@ -207,8 +209,9 @@ mover_new(struct pmem2_map *map, struct vdm **vdm)
void
mover_delete(struct vdm *dms)
{
LOG(3, "dms %p", dms);
membuf_delete(((struct data_mover *)dms)->membuf);
free((struct data_mover *)dms);
Free((struct data_mover *)dms);
}

/*
Expand Down
6 changes: 0 additions & 6 deletions src/test/pmem2_integration/TESTS.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,6 @@ class TEST38(PMEM2_INTEGRATION):
test_case = "test_unaligned_persist"


# XXX disable the test for `memcheck'
# until https://github.com/pmem/pmdk/issues/5637 is fixed.
@t.require_valgrind_disabled('memcheck')
class TEST39(PMEM2_INTEGRATION):
"""compare normal map vs map_from_existing"""
test_case = "test_map_from_existing"
Expand All @@ -303,9 +300,6 @@ class TES40(PMEM2_INTEGRATION):


@t.windows_exclude
# XXX disable the test for `memcheck'
# until https://github.com/pmem/pmdk/issues/5637 is fixed.
@t.require_valgrind_disabled('memcheck')
class TEST41(PMEM2_INTEGRATION_DEV_DAXES):
"""compare normal map vs map_from_existing on devdax"""
test_case = "test_map_from_existing"
9 changes: 0 additions & 9 deletions src/test/pmem2_map_from_existing/TESTS.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,16 @@ def run(self, ctx):
ctx.exec('pmem2_map_from_existing', self.test_case, filepath)


# XXX disable the test for `memcheck'
# until https://github.com/pmem/pmdk/issues/5594 is fixed.
@t.require_valgrind_disabled('memcheck')
class TEST0(Pmem2_from_existing):
"""try to create two the same mappings"""
test_case = "test_two_same_mappings"


# XXX disable the test for `memcheck'
# until https://github.com/pmem/pmdk/issues/5594 is fixed.
@t.require_valgrind_disabled('memcheck')
class TEST1(Pmem2_from_existing):
"""try to map which overlap bottom part of existing mapping"""
test_case = "test_mapping_overlap_bottom"


# XXX disable the test for `memcheck'
# until https://github.com/pmem/pmdk/issues/5594 is fixed.
@t.require_valgrind_disabled('memcheck')
class TEST2(Pmem2_from_existing):
"""try to map which overlap upper part of existing mapping"""
test_case = "test_mapping_overlap_upper"
Expand Down
5 changes: 4 additions & 1 deletion src/test/pmem2_map_from_existing/pmem2_map_from_existing.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2020-2021, Intel Corporation */
/* Copyright 2020-2023, Intel Corporation */

/*
* pmem2_map_from_existing.c -- pmem2_map_from_existing unittests
Expand Down Expand Up @@ -37,6 +37,7 @@ test_two_same_mappings(const struct test_case *tc, int argc, char *argv[])
UT_ASSERTeq(map2, NULL);

pmem2_map_delete(&map1);
pmem2_source_delete(&src);
CLOSE(fd);
return 1;
}
Expand Down Expand Up @@ -69,6 +70,7 @@ test_mapping_overlap_bottom(const struct test_case *tc, int argc, char *argv[])
UT_ASSERTeq(map2, NULL);

pmem2_map_delete(&map1);
pmem2_source_delete(&src);
CLOSE(fd);
return 1;
}
Expand Down Expand Up @@ -101,6 +103,7 @@ test_mapping_overlap_upper(const struct test_case *tc, int argc, char *argv[])
UT_ASSERTeq(map2, NULL);

pmem2_map_delete(&map1);
pmem2_source_delete(&src);
CLOSE(fd);
return 1;
}
Expand Down