From: Timo Sirainen Date: Fri, 19 May 2017 08:05:22 +0000 (+0300) Subject: lib-storage: Don't crash if cache is thought broken for a newly saved mail X-Git-Tag: 2.3.0.rc1~1590 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c44fcb83f26c0a86fbcdef05036aa4daa5e1da2e;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Don't crash if cache is thought broken for a newly saved mail It's a bug that it happens, but the resulting crash is confusing. Although arguably this new error could be i_panic() instead. Fixes: Panic: file mail-index-transaction-update.c: line 1018 (mail_index_update_ext): assertion failed: (seq > 0 && (seq <= mail_index_view_get_messages_count(t->view) || seq <= t->last_new_seq)) --- diff --git a/src/lib-storage/index/index-mail.c b/src/lib-storage/index/index-mail.c index 0d284890d2..0b920691da 100644 --- a/src/lib-storage/index/index-mail.c +++ b/src/lib-storage/index/index-mail.c @@ -2343,7 +2343,12 @@ void index_mail_set_cache_corrupted(struct mail *mail, mail_cache_transaction_reset(mail->transaction->cache_trans); imail->data.no_caching = TRUE; imail->data.forced_no_caching = TRUE; - if (reason[0] == '\0') { + + if (mail->saving) { + mail_storage_set_critical(mail->box->storage, + "BUG: Broken %s found in mailbox %s while saving a new mail: %s", + field_name, mail->box->vname, reason); + } else if (reason[0] == '\0') { mail_set_mail_cache_corrupted(mail, "Broken %s in mailbox %s", field_name, mail->box->vname);