Message ID | 1581590221-10437-1-git-send-email-damjan.skvarc@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | [ovs-dev,ovn] test-ovn: fix memory leak | expand |
On Thu, Feb 13, 2020 at 11:37:01AM +0100, Damijan Skvarc wrote: > Many memory leaks were detected by valgrind while running > "3-term numeric expression simplification" unit test. All of them > are reported in a form similar to: Thanks, applied to master.
diff --git a/tests/test-ovn.c b/tests/test-ovn.c index 8ef886d..c607a8f 100644 --- a/tests/test-ovn.c +++ b/tests/test-ovn.c @@ -913,7 +913,7 @@ test_tree_shape_exhaustively(struct expr *expr, struct shash *symtab, } else if (operation >= OP_SIMPLIFY) { modified = expr_simplify(expr_clone(expr)); modified = expr_evaluate_condition( - expr_clone(modified), tree_shape_is_chassis_resident_cb, NULL); + modified, tree_shape_is_chassis_resident_cb, NULL); ovs_assert(expr_honors_invariants(modified)); if (operation >= OP_NORMALIZE) {
Many memory leaks were detected by valgrind while running "3-term numeric expression simplification" unit test. All of them are reported in a form similar to: ==25922== 57,071,464 bytes in 192,809 blocks are definitely lost in loss record 70 of 70 ==25922== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==25922== by 0x468604: xmalloc (util.c:138) ==25922== by 0x5354B1: expr_create_boolean (expr.c:222) ==25922== by 0x5354B1: expr_fix_andor (expr.c:268) ==25922== by 0x536F0F: expr_simplify (expr.c:2108) ==25922== by 0x409C73: test_tree_shape_exhaustively (test-ovn.c:914) ==25922== by 0x40A83E: test_exhaustive (test-ovn.c:1140) ==25922== by 0x4110D3: ovs_cmdl_run_command__ (command-line.c:247) ==25922== by 0x407B01: test_ovn_main (test-ovn.c:1623) ==25922== by 0x407B01: ovstest_wrapper_test_ovn_main__ (test-ovn.c:1626) ==25922== by 0x4110D3: ovs_cmdl_run_command__ (command-line.c:247) ==25922== by 0x4066B9: main (ovstest.c:133) The problem was in test_tree_shape_exhaustively() function which overides pointer to temporary allocated expression without freeing it first. Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com> --- tests/test-ovn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)