Re: dbmail-export segfaults on one user, user has messages but cannot retrieve them via imapd or pop3d

Lee Howard <[email protected]> Tue, 17 Mar 2015 15:10:40 -0700
Newsgroups gmane.mail.imap.dbmail.devel
Message-ID <[email protected]>
On 03/16/2015 01:39 PM, Lee Howard wrote:
> Something appears to be corrupt with one user's inbox and this is 
> causing dbmail-export to segfault.
>
> dbmail-util does not seem to fix the problem.
>
> The user cannot retrieve any mail via dbmail-imapd or dbmail-pop3d 
> although imapd does show messages available.
>
> Other users are not experiencing any problem.  So it would seem to be 
> something corrupt in the database for the one user.

The dbmail-export segfault is fixed by the attached patch. 
dbmail_message_retrieve() can return NULL, and this condition was not 
being handled.

I note that a NULL return from dbmail_message_retrieve() is also not 
handled in both src/dm_http.c and src/maintenance.c, but I did not 
address these since my immediate use would not have allowed me to test 
any code changes to there.  I will leave that to you.

dbmail-util was not repairing the problem with the offending/corrupt 
mail message.

To resolve the problem I merely had dbmail-export printf the 
physmessage_id number of the message that caused 
dbmail_message_retrieve() to return NULL (123258), and then I did:

MariaDB [dbmail]> delete from dbmail_physmessage where id = '123258';
Query OK, 1 row affected (0.07 sec)

Once that was done then my e-mail client was able to retrieve all of the 
backlogged e-mail as normal and expected.

I am not entirely certain what was wrong with that one message.  I did 
note that:

MariaDB [dbmail]> select * from dbmail_partlists where physmessage_id = 
'123258';
Empty set (0.00 sec)

Since I'm not an expert on the way dbmail expects a mail to be 
represented in the database I'm not sure if that was the offending matter.

However, I would like to see dbmail-util resolve this condition.  I 
would much-prefer to just run dbmail-util than to run hard-code a printf 
into dbmail-export and then delete a record from the database.  What can 
I do?

Thanks,

Lee.

_______________________________________________
Dbmail-dev mailing list
[email protected]
http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail-dev
dbmail-nullmessagefix.patch (text/x-patch, 439 B)
--- src/dm_mailbox.c.orig	2015-03-17 13:02:42.682133322 -0700
+++ src/dm_mailbox.c	2015-03-17 13:00:41.356141081 -0700
@@ -226,7 +226,7 @@
 		mempool_push(self->pool, p_list_data(ids), sizeof(uint64_t));
 		m = dbmail_message_new(self->pool);
 		m = dbmail_message_retrieve(m, physid);
-		if (dump_message_to_stream(self, m, ostream) > 0)
+		if (m && dump_message_to_stream(self, m, ostream) > 0)
 			count++;
 		dbmail_message_free(m);