Updating keywords on copy/move

Daniele Ricci daniele.athome at gmail.com
Sat Oct 14 22:40:15 EEST 2017


Hello,
I'm working on my virtual keywords plugin [1] to add an apparently
simple feature: add a keyword to a message when it is moved or copied
into a virtual folder (let's forget about what keyword to add, I'm
starting with a hard-coded one to understand Dovecot plugin
development).

So I've added a mail_copy hook by the notify plugin [2] and did a
simple call to mail_update_keywords [3]. The current source code shows
a call to mail_get_backend_mail, this is me experimenting, I've also
tried calling mail_update_keywords directly on "dst" mail.

The result is an imap crash:

Oct 14 21:22:26 notebook dovecot: imap(daniele): Panic: file
mail-log-plugin.c: line 461 (mail_log_mail_transaction_commit):
assertion failed: (msg->pretext == NULL)
Oct 14 21:22:26 notebook dovecot: imap(daniele): Error: Raw backtrace:
/usr/lib/dovecot/libdovecot.so.0(+0x9f0a2) [0x7f81af52f0a2] ->
/usr/lib/dovecot/libdovecot.so.0(+0x9f19a) [0x7f81af52f19a] ->
/usr/lib/dovecot/libdovecot.so.0(i_fatal+0) [0x7f81af4bfcf8] ->
/usr/lib/dovecot/modules/lib20_mail_log_plugin.so(+0x19e8) [0x7f81aeae89e8] ->
/usr/lib/dovecot/modules/lib15_notify_plugin.so(notify_contexts_mail_transaction_commit+0x58)
[0x7f81aecec548] ->
/usr/lib/dovecot/modules/lib15_notify_plugin.so(+0x2105) [0x7f81aeced105] ->
/usr/lib/dovecot/libdovecot-storage.so.0(mailbox_transaction_commit_get_changes+0x52)
[0x7f81af807ca2] ->
/usr/lib/dovecot/libdovecot-storage.so.0(mailbox_transaction_commit+0x21)
[0x7f81af807d71] ->
/usr/lib/dovecot/modules/lib20_virtual_plugin.so(virtual_transaction_commit+0x78)
[0x7f81ae8e2fb8] ->
/usr/lib/dovecot/modules/lib15_notify_plugin.so(+0x20ec) [0x7f81aeced0ec] ->
/usr/lib/dovecot/libdovecot-storage.so.0(mailbox_transaction_commit_get_changes+0x52)
[0x7f81af807ca2] ->
dovecot/imap(+0x10084) [0x563d0ff2b084] ->
dovecot/imap(command_exec+0x5c) [0x563d0ff37d9c] ->
dovecot/imap(+0x1b322) [0x563d0ff36322] -> dovecot/imap(+0x1b3bc)
[0x563d0ff363bc] ->
dovecot/imap(client_handle_input+0x18d) [0x563d0ff3677d] ->
dovecot/imap(client_input+0xac) [0x563d0ff36ccc] ->
/usr/lib/dovecot/libdovecot.so.0(io_loop_call_io+0x52) [0x7f81af544742] ->
/usr/lib/dovecot/libdovecot.so.0(io_loop_handler_run_internal+0x12e)
[0x7f81af545d8e] ->
/usr/lib/dovecot/libdovecot.so.0(io_loop_handler_run+0x36) [0x7f81af5447d6] ->
/usr/lib/dovecot/libdovecot.so.0(io_loop_run+0x38) [0x7f81af544988] ->
/usr/lib/dovecot/libdovecot.so.0(master_service_run+0x13) [0x7f81af4ca353] ->
dovecot/imap(main+0x329) [0x563d0ff29139] ->
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1)
[0x7f81af1132e1] ->
dovecot/imap(_start+0x2a) [0x563d0ff292ca]

This happens after my hook returns.
Now, before activating core dumps and starting to do some serious
debugging and reverse engineering, I ask: do I have to do something
extra such as opening a transaction or something? Isn't the notify
plugin supposed to do that already?

Thanks for your help!

[1] http://github.com/daniele-athome/dovecot-virtual-keywords-plugin
[2] https://github.com/daniele-athome/dovecot-virtual-keywords-plugin/blob/keyword-on-copy/virtual-keywords-plugin.c#L195
[3] https://github.com/daniele-athome/dovecot-virtual-keywords-plugin/blob/keyword-on-copy/virtual-keywords-plugin.c#L149

-- 
Daniele


More information about the dovecot mailing list