Hi,

I've configured virtual mailboxes and it is working well, including the setting of the real mailbox that will receive messages moved to it.

Problem starts when I try to use imapsieve plugin with this setup, I receive a panic on the log and the action isn't executed.

To make the problem appears, all that its needed is to have a virtual folder defined with the real mailbox configured (! prefix on the virtual configuration file), having the imapsieve options enabled on dovecot configuration and a sieve script defined.

Error occurs even if the sieve script is empty.

This error was already reported back in 2017: https://www.dovecot.org/list/dovecot/2017-September/109445.html

This is the relevant configuration for imapsieve:

plugin {
  imapsieve_mailbox1_before = file:/etc/wwmail/antispamsieve/learn.sieve
  imapsieve_mailbox1_causes = COPY APPEND
  imapsieve_mailbox1_name = *
  sieve_global_path = /var/lib/dovecot/sieve/default.sieve
  sieve_pipe_bin_dir = /etc/wwmail/antispamsieve/
  sieve_plugins = sieve_imapsieve sieve_extprograms
}

This is the error received:

Oct 27 16:25:06 lab dovecot: imap(monitor@lab.wwmail.app)<28726><ug8CjVrPIqoAAAAAAAAAAAAAAAAAAAAB>: Panic: file mail-index-map.c: line 558 (mail_index_map_lookup_seq_range): assertion failed: (first_uid > 0)

Oct 27 16:25:06 lab dovecot: imap(monitor@lab.wwmail.app)<28726><ug8CjVrPIqoAAAAAAAAAAAAAAAAAAAAB>: Error: Raw backtrace: /usr/lib/dovecot/libdovecot.so.0(backtrace_append+0x42) [0x7f8f68fe1b52] -> /usr/lib/dovecot/libdovecot.so.0(backtrace_get+0x1e) [0x7f8f68fe1c6e] -> /usr/lib/dovecot/libdovecot.so.0(+0xff41b) [0x7f8f68ff041b] -> /usr/lib/dovecot/libdovecot.so.0(+0xff4b1) [0x7f8f68ff04b1] -> /usr/lib/dovecot/libdovecot.so.0(+0x5427c) [0x7f8f68f4527c] -> /usr/lib/dovecot/libdovecot-storage.so.0(+0x49e07) [0x7f8f69104e07] -> /usr/lib/dovecot/libdovecot-storage.so.0(+0xf00a9) [0x7f8f691ab0a9] -> /usr/lib/dovecot/libdovecot-storage.so.0(mail_index_lookup_seq+0xf) [0x7f8f691b3e0f] -> /usr/lib/dovecot/modules/lib20_virtual_plugin.so(+0x829c) [0x7f8f68b1029c] -> /usr/lib/dovecot/libdovecot-storage.so.0(mail_set_uid+0x35) [0x7f8f6910a9a5] -> /usr/lib/dovecot/modules/lib95_imap_sieve_plugin.so(+0x8cf2) [0x7f8f68b01cf2] -> /usr/lib/dovecot/libdovecot-storage.so.0(mailbox_transaction_commit_get_changes+0x56) [0x7f8f69117806] -> dovecot/imap(+0x1584d) [0x56322e61784d] -> dovecot/imap(command_exec+0xa4) [0x56322e621cf4] -> dovecot/imap(+0x25bbf) [0x56322e627bbf] -> dovecot/imap(+0x25c6b) [0x56322e627c6b] -> dovecot/imap(+0x25f04) [0x56322e627f04] -> dovecot/imap(client_handle_input+0x1b5) [0x56322e6280d5] -> dovecot/imap(client_input+0x70) [0x56322e628490] -> /usr/lib/dovecot/libdovecot.so.0(io_loop_call_io+0x69) [0x7f8f690067d9] -> /usr/lib/dovecot/libdovecot.so.0(io_loop_handler_run_internal+0x132) [0x7f8f69008642] -> /usr/lib/dovecot/libdovecot.so.0(io_loop_handler_run+0x50) [0x7f8f690086f0] -> /usr/lib/dovecot/libdovecot.so.0(io_loop_run+0x40) [0x7f8f690088b0] -> /usr/lib/dovecot/libdovecot.so.0(master_service_run+0x13) [0x7f8f68f78dd3] -> dovecot/imap(main+0x500) [0x56322e613fc0] -> /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xea) [0x7f8f68d4cd0a] -> dovecot/imap(_start+0x2a) [0x56322e6140ba]

I am using packages of Debian Bookworm (testing) but the problem already occured on Debian Buster.

Packages installed

# dpkg --list | grep dovecot | awk '{print $2 " "  $3}'
dovecot-antispam 2.0+20171229-1+b8
dovecot-core 1:2.3.16+dfsg1-3
dovecot-imapd 1:2.3.16+dfsg1-3
dovecot-lmtpd 1:2.3.16+dfsg1-3
dovecot-managesieved 1:2.3.16+dfsg1-3
dovecot-mysql 1:2.3.16+dfsg1-3
dovecot-pop3d 1:2.3.16+dfsg1-3
dovecot-sieve 1:2.3.16+dfsg1-3


Please take a look at it.

I can help provide more information if needed, but I think all relevant information to reproduce the bug is here.

Best regards,
Claudemir