From 29086c84f6bd93afbe985e70fd142db4cd78f4b2 Mon Sep 17 00:00:00 2001 From: Jan Radon Date: Sat, 14 Jul 2018 21:27:21 +0200 Subject: [PATCH] #174: fix mailbox delete valgrind check:-> added suppression file for dovecot memory issue (missing cleanup extra attributes) --- src/storage-rbox/doveadm-rbox-plugin.cpp | 6 +- src/storage-rbox/doveadm-rbox-plugin.h | 1 - src/tests/Makefile.am | 2 +- src/tests/doveadm-rmb/it_test_doveadm_rmb.cpp | 11 +++- src/tests/dovecot.supp | 64 +++++++++++++++++++ 5 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 src/tests/dovecot.supp diff --git a/src/storage-rbox/doveadm-rbox-plugin.cpp b/src/storage-rbox/doveadm-rbox-plugin.cpp index 72f1f8c6..01395f98 100644 --- a/src/storage-rbox/doveadm-rbox-plugin.cpp +++ b/src/storage-rbox/doveadm-rbox-plugin.cpp @@ -800,9 +800,8 @@ static int cmd_mailbox_delete_run(struct doveadm_mail_cmd_context *_ctx, struct mailbox_flags |= MAILBOX_FLAG_DELETE_UNSAFE; #endif - i_debug("cmd_mailbox_delete_run"); - if (ctx->recursive) { + i_debug("not recursive !"); t_array_init(&recursive_mailboxes, 32); array_foreach(&ctx->mailboxes, namep) { if (get_child_mailboxes(user, &recursive_mailboxes, *namep) < 0) { @@ -934,7 +933,7 @@ static void cmd_rmb_mailbox_delete_init(struct doveadm_mail_cmd_context *_ctx AT } doveadm_mailbox_args_check(args); for (i = 0; args[i] != NULL; i++) { - name = p_strdup(ctx->pool, args[i]); + name = p_strdup(_ctx->pool, args[i]); array_append(&ctx->mailboxes, &name, 1); } array_sort(&ctx->mailboxes, i_strcmp_reverse_p); @@ -1050,7 +1049,6 @@ struct doveadm_mail_cmd_context *cmd_rmb_mailbox_delete_alloc(void) { ctx->ctx.v.init = cmd_rmb_mailbox_delete_init; ctx->ctx.v.parse_arg = cmd_mailbox_delete_parse_arg; ctx->ctx.getopt_args = "rs"; - ctx->pool = pool_alloconly_create("doveadm mailbox delete pool", 512); p_array_init(&ctx->mailboxes, ctx->ctx.pool, 16); return &ctx->ctx; } diff --git a/src/storage-rbox/doveadm-rbox-plugin.h b/src/storage-rbox/doveadm-rbox-plugin.h index 1820318a..b413f476 100644 --- a/src/storage-rbox/doveadm-rbox-plugin.h +++ b/src/storage-rbox/doveadm-rbox-plugin.h @@ -26,7 +26,6 @@ struct delete_cmd_context { bool unsafe; #endif bool subscriptions; - pool_t pool; }; extern struct doveadm_mail_cmd_context *cmd_rmb_ls_alloc(void); diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am index f835a8e0..236103e7 100644 --- a/src/tests/Makefile.am +++ b/src/tests/Makefile.am @@ -169,4 +169,4 @@ noinst_PROGRAMS = $(TESTS) @CODE_COVERAGE_RULES@ @VALGRIND_CHECK_RULES@ -VALGRIND_SUPPRESSIONS_FILES = dict_rados.supp open_connection.supp +VALGRIND_SUPPRESSIONS_FILES = dict_rados.supp open_connection.supp dovecot.supp diff --git a/src/tests/doveadm-rmb/it_test_doveadm_rmb.cpp b/src/tests/doveadm-rmb/it_test_doveadm_rmb.cpp index bb9fa106..6b0cd41a 100644 --- a/src/tests/doveadm-rmb/it_test_doveadm_rmb.cpp +++ b/src/tests/doveadm-rmb/it_test_doveadm_rmb.cpp @@ -383,17 +383,22 @@ TEST_F(DoveadmTest, cmd_rmb_delete_mailbox) { std::stringstream ss; - char *argv2[] = {"INBOX"}; + char *argv2[] = {"INBOX\0"}; struct doveadm_mail_cmd_context *cmd_ctx = cmd_rmb_mailbox_delete_alloc(); struct delete_cmd_context *ctx = (struct delete_cmd_context *)cmd_ctx; - ctx->recursive = TRUE; + ctx->recursive = FALSE; cmd_ctx->args = argv2; cmd_ctx->iterate_single_user = true; - char *name = p_strdup(cmd_ctx->pool, argv2[0]); + std::string mailbox_name = "INBOX"; + char *name = p_strdup(cmd_ctx->pool, mailbox_name.c_str()); + array_append(&ctx->mailboxes, &name, 1); cmd_ctx->v.run(cmd_ctx, DoveadmTest::s_test_mail_user); + ASSERT_EQ(cmd_ctx->exit_code, 0); + struct list_cmd_context *ctx2 = (struct list_cmd_context *)cmd_ctx; + pool_unref(&cmd_ctx->pool); } diff --git a/src/tests/dovecot.supp b/src/tests/dovecot.supp new file mode 100644 index 00000000..6b52bfc9 --- /dev/null +++ b/src/tests/dovecot.supp @@ -0,0 +1,64 @@ +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:calloc + fun:pool_system_malloc + fun:p_malloc + fun:buffer_create_dynamic + fun:array_create_i + fun:mailbox_attribute_iter_init + fun:mailbox_delete_all_attributes + fun:mailbox_expunge_all_data + fun:index_storage_mailbox_delete_pre + fun:index_storage_mailbox_delete + fun:rbox_storage_mailbox_delete + fun:mailbox_delete + fun:_ZL22cmd_mailbox_delete_runP24doveadm_mail_cmd_contextP9mail_user + fun:_ZL26cmd_rmb_mailbox_delete_runP24doveadm_mail_cmd_contextP9mail_user + fun:_ZN39DoveadmTest_cmd_rmb_delete_mailbox_Test8TestBodyEv + fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc + fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc + fun:_ZN7testing4Test3RunEv + fun:_ZN7testing8TestInfo3RunEv + fun:_ZN7testing8TestCase3RunEv + fun:_ZN7testing8internal12UnitTestImpl11RunAllTestsEv + fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS0_12UnitTestImplEbEET0_PT_MS4_FS3_vEPKc + fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS0_12UnitTestImplEbEET0_PT_MS4_FS3_vEPKc + fun:_ZN7testing8UnitTest3RunEv + fun:_Z13RUN_ALL_TESTSv + fun:main +} + +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:calloc + fun:pool_system_malloc + fun:p_malloc + fun:buffer_create_dynamic + fun:array_create_i + fun:mailbox_attribute_iter_init + fun:mailbox_delete_all_attributes + fun:mailbox_expunge_all_data + fun:index_storage_mailbox_delete_pre + fun:index_storage_mailbox_delete + fun:rbox_storage_mailbox_delete + fun:mailbox_delete + fun:_ZL22cmd_mailbox_delete_runP24doveadm_mail_cmd_contextP9mail_user + fun:_ZL26cmd_rmb_mailbox_delete_runP24doveadm_mail_cmd_contextP9mail_user + fun:_ZN39DoveadmTest_cmd_rmb_delete_mailbox_Test8TestBodyEv + fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc + fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc + fun:_ZN7testing4Test3RunEv + fun:_ZN7testing8TestInfo3RunEv + fun:_ZN7testing8TestCase3RunEv + fun:_ZN7testing8internal12UnitTestImpl11RunAllTestsEv + fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS0_12UnitTestImplEbEET0_PT_MS4_FS3_vEPKc + fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS0_12UnitTestImplEbEET0_PT_MS4_FS3_vEPKc + fun:_ZN7testing8UnitTest3RunEv + fun:_Z13RUN_ALL_TESTSv + fun:main +} +