Panic during IMAP APPEND

Stephan Bosch stephan at rename-it.nl
Mon Sep 20 23:29:33 EEST 2021


Tracking this issue internally as DOP-2557.


On 20/09/2021 22:12, Stephan Bosch wrote:
>
>
> On 20/09/2021 18:04, Gedalya wrote:
>> I don't know how I can tell which mailbox is selected / being 
>> appended to.
>>
>> Mailbox format is Maildir. Filesystem is XFS.
>>
>> System was upgraded from 2.2.36.1 to 2.3.16, and it seems this 
>> started happening following that.
>>
>> Sep 20 15:49:34 imap1 dovecot: imap(u at d)<17673><jfjuOW/Mf+xEgdSK>: 
>> Panic: file mail-index-map.c: line 558 
>> (mail_index_map_lookup_seq_range): assertion failed: (first_uid > 0)
>> Sep 20 15:49:34 imap1 dovecot: imap(u at d)<17673><jfjuOW/Mf+xEgdSK>: 
>> Error: Raw backtrace: 
>> /usr/lib/dovecot/libdovecot.so.0(backtrace_append+0x42) 
>> [0x7f363c72dc22] -> 
>> /usr/lib/dovecot/libdovecot.so.0(backtrace_get+0x1e) [0x7f363c72dd3e] 
>> -> /usr/lib/dovecot/libdovecot.so.0(+0xff47b) [0x7f363c73c47b] -> 
>> /usr/lib/dovecot/libdovecot.so.0(+0xff511) [0x7f363c73c511] -> 
>> /usr/lib/dovecot/libdovecot.so.0(+0x5427c) [0x7f363c69127c] -> 
>> /usr/lib/dovecot/libdovecot-storage.so.0(+0x49e07) [0x7f363c84fe07] 
>> -> /usr/lib/dovecot/libdovecot-storage.so.0(+0xf0499) 
>> [0x7f363c8f6499] -> 
>> /usr/lib/dovecot/libdovecot-storage.so.0(mail_index_lookup_seq+0xf) 
>> [0x7f363c8ff20f] -> 
>> /usr/lib/dovecot/libdovecot-storage.so.0(index_mail_set_uid+0x2f) 
>> [0x7f363c8cf79f] -> 
>> /usr/lib/dovecot/libdovecot-storage.so.0(mail_set_uid+0x35) 
>> [0x7f363c8559a5] -> 
>> /usr/lib/dovecot/modules/lib95_imap_sieve_plugin.so(+0x8d02) 
>> [0x7f363c255d02] -> 
>> /usr/lib/dovecot/modules/lib10_quota_plugin.so(+0x130f4) 
>> [0x7f363c45e0f4] ->
>> /usr/lib/dovecot/libdovecot-storage.so.0(mailbox_transaction_commit_get_changes+0x56) 
>> [0x7f363c8628a6] -> dovecot/imap [u at d xx.xx.xx.xx APPEND](+0x13e10) 
>> [0x55eae70f8e10] -> dovecot/imap [u at d xx.xx.xx.xx 
>> APPEND](command_exec+0xa4) [0x55eae7104844] -> dovecot/imap [u at d 
>> xx.xx.xx.xx APPEND](+0x1333b) [0x55eae70f833b] -> 
>> /usr/lib/dovecot/libdovecot.so.0(io_loop_call_io+0x69) 
>> [0x7f363c752869] -> 
>> /usr/lib/dovecot/libdovecot.so.0(io_loop_handler_run_internal+0x132) 
>> [0x7f363c7546d2] -> 
>> /usr/lib/dovecot/libdovecot.so.0(io_loop_handler_run+0x50) 
>> [0x7f363c754780] -> 
>> /usr/lib/dovecot/libdovecot.so.0(io_loop_run+0x40) [0x7f363c754940] 
>> -> /usr/lib/dovecot/libdovecot.so.0(master_service_run+0x13) 
>> [0x7f363c6c4dd3] -> dovecot/imap [u at d xx.xx.xx.xx APPEND](main+0x500) 
>> [0x55eae70f7120] -> 
>> /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xea) 
>> [0x7f363c49ad0a] -> dovecot/imap [u at d xx.xx.xx.xx 
>> APPEND](_start+0x2a) [0x55eae70f721a]
>> Sep 20 15:49:34 imap1 dovecot: imap(u at d)<17673><jfjuOW/Mf+xEgdSK>: 
>> Fatal: master: service(imap): child 17673 killed with signal 6 (core 
>> dumped)
>
> I am not sure how this starts happening now. I don't see changes in 
> the imapsieve code that could cause this. But the existing code does 
> have a path towards this problem. If you have the opportunity to apply 
> and test patches, this should fix it:
>
> diff --git a/src/plugins/imapsieve/imap-sieve-storage.c 
> b/src/plugins/imapsieve/imap-sieve-storage.c
> index 53761c64e..1c9131af5 100644
> --- a/src/plugins/imapsieve/imap-sieve-storage.c
> +++ b/src/plugins/imapsieve/imap-sieve-storage.c
> @@ -581,6 +581,7 @@ imap_sieve_mailbox_run_copy_source(
>                 return;
>
>         i_assert(ismt->src_mail_trans->box == src_box);
> +       i_assert(mevent->src_mail_uid > 0);
>
>         if (*src_mail == NULL)
>                 *src_mail = mail_alloc(ismt->src_mail_trans, 0, NULL);
> @@ -741,11 +742,18 @@ imap_sieve_mailbox_transaction_run(
>                 bool fatal;
>
>                 /* Determine UID for saved message */
> -               if (mevent->dest_mail_uid > 0 ||
> -                       !seq_range_array_iter_nth(&siter, 
> mevent->save_seq, &uid))
> +               if (mevent->dest_mail_uid > 0
>                         uid = mevent->dest_mail_uid;
> +               else if (!seq_range_array_iter_nth(&siter, 
> mevent->save_seq,
> +                                                  &uid)) {
> +                       /* already gone for some reason */
> +                       imap_sieve_mailbox_debug(
> +                               sbox, "Message for Sieve event gone");
> +                       continue;
> +               }
>
>                 /* Select event message */
> +               i_assert(uid > 0);
>                 if (!mail_set_uid(mail, uid) || mail->expunged) {
>                         /* already gone for some reason */
>                         imap_sieve_mailbox_debug(sbox,
>
>
>>
>> # doveconf -n
>> # 2.3.16 (): /etc/dovecot/dovecot.conf
>> # Pigeonhole version 0.5.16 (09c29328)
>> # OS: Linux 5.10.0-8-amd64 x86_64 Debian 11.0
>> # Hostname: imap1.xxxxx.com
>> auth_default_realm = xxxxx.com
>> auth_master_user_separator = *
>> auth_mechanisms = plain login cram-md5
>> auth_proxy_self = xxxxxxxxxx
>> auth_verbose = yes
>> auth_verbose_passwords = plain
>> dict {
>>    lastlogin = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext
>>    quota = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext
>> }
>> disable_plaintext_auth = no
>> doveadm_password = # hidden, use -P to show it
>> imap_hibernate_timeout = 10 secs
>> lmtp_rcpt_check_quota = yes
>> log_timestamp = "%Y-%m-%d %H:%M:%S "
>> login_greeting = Dovecot ready
>> login_log_format_elements = user=<%u> method=%m rip=%r lip=%l 
>> pip=%{real_rip} mpid=%e %c %k session=<%{session}>
>> login_trusted_networks = xxxxxxxxxxxxxxxxx
>> mail_attachment_detection_options = add-flags-on-save
>> mail_gid = vmail
>> mail_location = /nowhere
>> mail_plugins = quota listescape
>> mail_privileged_group = mail
>> mail_uid = vmail
>> managesieve_sieve_capability = fileinto envelope encoded-character 
>> subaddress comparator-i;ascii-numeric relational regex imap4flags 
>> copy include variables mailbox date index ihave duplicate mime 
>> foreverypart extracttext
>> namespace inbox {
>>    inbox = yes
>>    location =
>>    mailbox Drafts {
>>      auto = subscribe
>>      special_use = \Drafts
>>    }
>>    mailbox Junk {
>>      auto = subscribe
>>      autoexpunge = 30 days
>>      special_use = \Junk
>>    }
>>    mailbox Sent {
>>      auto = subscribe
>>      special_use = \Sent
>>    }
>>    mailbox "Sent Messages" {
>>      special_use = \Sent
>>    }
>>    mailbox Trash {
>>      auto = subscribe
>>      autoexpunge = 30 days
>>      special_use = \Trash
>>    }
>>    mailbox Trash/* {
>>      autoexpunge = 30 days
>>    }
>>    prefix =
>>    separator = /
>>    type = private
>> }
>> passdb {
>>    args = /etc/dovecot/master-users
>>    driver = passwd-file
>>    master = yes
>>    pass = yes
>> }
>> passdb {
>>    args = /etc/dovecot/dovecot-sql.conf.ext
>>    driver = sql
>> }
>> plugin {
>>    imapsieve_mailbox1_before = 
>> file:/usr/local/lib/imapsieve/report-spam.sieve
>>    imapsieve_mailbox1_causes = COPY APPEND
>>    imapsieve_mailbox1_name = Junk
>>    imapsieve_mailbox2_before = 
>> file:/usr/local/lib/imapsieve/report-ham.sieve
>>    imapsieve_mailbox2_causes = COPY
>>    imapsieve_mailbox2_from = Junk
>>    imapsieve_mailbox2_name = *
>>    imapsieve_mailbox3_before = 
>> file:/usr/local/lib/imapsieve/report-ham.sieve
>>    imapsieve_mailbox3_causes = APPEND
>>    imapsieve_mailbox3_name = INBOX
>>    last_login_dict = proxy::lastlogin
>>    last_login_key = # hidden, use -P to show it
>>    quota = dict:user::proxy::quota
>>    quota_rule = *:storage=2G
>>    quota_rule2 = Trash:storage=+250M
>>    quota_rule3 = Junk:ignore
>>    quota_vsizes = yes
>>    quota_warning = storage=95%% quota-warning 95 %u
>>    quota_warning2 = storage=85%% quota-warning 85 %u
>>    sieve = file:~/sieve;active=~/.dovecot.sieve
>>    sieve_before = /etc/dovecot/sieve-global/fileinto-spam.sieve
>>    sieve_extensions = -vacation -body -reject -enotify -environment 
>> -virustest -spamtest
>>    sieve_global_extensions = +vnd.dovecot.pipe +vnd.dovecot.environment
>>    sieve_max_actions = 32
>>    sieve_max_redirects = 4
>>    sieve_max_script_size = 10K
>>    sieve_pipe_bin_dir = /usr/local/lib/imapsieve
>>    sieve_plugins = sieve_imapsieve sieve_extprograms
>>    sieve_quota_max_scripts = 100
>>    sieve_quota_max_storage = 4M
>> }
>> pop3_fast_size_lookups = yes
>> pop3_no_flag_updates = yes
>> postmaster_address = postmaster at xxxxx.com
>> protocols = imap pop3 lmtp sieve
>> quota_full_tempfail = yes
>> service auth-worker {
>>    user = $default_internal_user
>> }
>> service auth {
>>    client_limit = 2448
>>    unix_listener auth-userdb {
>>      group = root
>>      mode = 0600
>>      user = vmail
>>    }
>> }
>> service dict {
>>    unix_listener dict {
>>      group = root
>>      mode = 0600
>>      user = vmail
>>    }
>> }
>> service imap-hibernate {
>>    unix_listener imap-hibernate {
>>      group = $default_internal_group
>>      mode = 0660
>>    }
>> }
>> service imap-login {
>>    process_min_avail = 4
>>    service_count = 0
>>    vsz_limit = 192 M
>> }
>> service imap {
>>    process_limit = 1024
>>    unix_listener imap-master {
>>      user = $default_internal_user
>>    }
>>    vsz_limit = 384 M
>> }
>> service lmtp {
>>    inet_listener lmtp {
>>      port = 7025
>>    }
>> }
>> service managesieve-login {
>>    inet_listener sieve {
>>      port = 4190
>>    }
>>    service_count = 0
>>    vsz_limit = 64 M
>> }
>> service managesieve {
>>    process_limit = 20
>> }
>> service pop3-login {
>>    process_min_avail = 4
>>    service_count = 0
>>    vsz_limit = 192 M
>> }
>> service pop3 {
>>    process_limit = 1024
>> }
>> service quota-warning {
>>    executable = script /usr/local/bin/quota-warning
>>    unix_listener quota-warning {
>>      user = vmail
>>    }
>>    user = dovecot
>> }
>> ssl_cert = </var/local/letsencrypt/live/xxxxxxxxxxx/fullchain.pem
>> ssl_client_ca_dir = /etc/ssl/certs
>> ssl_dh = # hidden, use -P to show it
>> ssl_key = # hidden, use -P to show it
>> ssl_min_protocol = TLSv1
>> userdb {
>>    driver = prefetch
>> }
>> userdb {
>>    args = /etc/dovecot/dovecot-sql.conf.ext
>>    driver = sql
>> }
>> verbose_proctitle = yes
>> protocol lmtp {
>>    mail_plugins = quota listescape sieve
>> }
>> protocol lda {
>>    mail_plugins = quota listescape sieve
>> }
>> protocol imap {
>>    mail_max_userip_connections = 20
>>    mail_plugins = quota listescape imap_quota imap_sieve last_login
>> }
>> protocol sieve {
>>    mail_max_userip_connections = 5
>> }
>> protocol pop3 {
>>    mail_max_userip_connections = 10
>>    mail_plugins = quota listescape last_login
>> }
>>
>



More information about the dovecot mailing list