Skip to content

Commit

Permalink
#174: fix mailbox delete valgrind check:-> added suppression file for…
Browse files Browse the repository at this point in the history
… dovecot memory issue (missing cleanup extra attributes)
  • Loading branch information
jrse committed Jul 14, 2018
1 parent 27452f2 commit 29086c8
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 9 deletions.
6 changes: 2 additions & 4 deletions src/storage-rbox/doveadm-rbox-plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion src/storage-rbox/doveadm-rbox-plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 8 additions & 3 deletions src/tests/doveadm-rmb/it_test_doveadm_rmb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
64 changes: 64 additions & 0 deletions src/tests/dovecot.supp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
<doveadm_test_extra_attributes_no_cleanup1>
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
}

{
<doveadm_test_extra_attributes_no_cleanup2>
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
}

0 comments on commit 29086c8

Please sign in to comment.