The following issue has been RESOLVED. 
====================================================================== 
http://dbmail.org/mantis/view.php?id=787 
====================================================================== 
Reported By:                maximP
Assigned To:                paul
====================================================================== 
Project:                    DBMail
Issue ID:                   787
Category:                   IMAP daemon
Reproducibility:            sometimes
Severity:                   crash
Priority:                   normal
Status:                     resolved
target:                      
Resolution:                 fixed
Fixed in Version:           
====================================================================== 
Date Submitted:             15-Jul-09 09:33 CEST
Last Modified:              17-Jul-09 22:42 CEST
====================================================================== 
Summary:                    dbmail-imapd dies (OOM killer?)
Description: 
Sometimes dbmail-imapd process dies without notices. Looks like there's a
memory leak which results to killing the process. Communication buffer size
was increased in 2.3.6, and the problem arises more often now.

PS. While this report is being written, resident memory usage of
dbmail-imapd process grew from 60M to 70M.

PPS. I have these errors in logs (several times per week):
Warning:[mailbox] dbmail_mailbox_get_set(+1549): mailbox info out of sync:
exists [544] ids [543]
Error:[mailbox] mailbox_search(+1489): key missing in self->ids: [29086]
Is it another problem?
====================================================================== 

---------------------------------------------------------------------- 
 (0002830) maximP (reporter) - 15-Jul-09 09:55
 http://dbmail.org/mantis/view.php?id=787#c2830 
---------------------------------------------------------------------- 
After turning off IDLE usage in Thunderbird, dbmail-imapd process memory
usage doesn't grow. 

---------------------------------------------------------------------- 
 (0002831) maximP (reporter) - 17-Jul-09 13:37
 http://dbmail.org/mantis/view.php?id=787#c2831 
---------------------------------------------------------------------- 
Valgrind says:

==13267== 6,323,112 (6,322,944 direct, 168 indirect) bytes in 24 blocks
are definitely lost in loss record 34 of 34
==13267==    at 0x4C23484: calloc (in
/usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so)
==13267==    by 0x5FE3859: g_malloc0 (in
/usr/lib64/libglib-2.0.so.0.1800.2)
==13267==    by 0x40CB0A: imap_handle_input (imap4.c:352)
==13267==    by 0x40C19F: imap_cb_read (imap4.c:154)
==13267==    by 0x40C217: socket_read_cb (imap4.c:164)
==13267==    by 0x66EF2C7: event_base_loop (in
/usr/lib64/libevent-1.4.so.2.1.0)
==13267==    by 0x4E72FA6: server_run (server.c:637)
==13267==    by 0x4E734C1: server_mainloop (server.c:761)
==13267==    by 0x41D746: main (imapd.c:70)

The fragment of imap4.c:

if ( session->command_type == IMAP_COMM_IDLE ) { // session is in a IDLE
loop
  TRACE(TRACE_DEBUG,"read [%s] while in IDLE loop", buffer);
  session->command_state = FALSE;
  dm_thread_data *D = g_new0(dm_thread_data,1); <-------- this is line
352
  D->data = (gpointer)g_strdup(buffer);
  g_async_queue_push(session->ci->queue, (gpointer)D);
  break;
}

Could it help to solve the problem? 

---------------------------------------------------------------------- 
 (0002832) maximP (reporter) - 17-Jul-09 13:53
 http://dbmail.org/mantis/view.php?id=787#c2832 
---------------------------------------------------------------------- 
Fragment of imap_idle_loop function in imapcommands.c:

data = g_async_queue_timed_pop(self->ci->queue, &end_time);
if (data) {
  dm_thread_data *D = (gpointer)data;
  message = (char *)D->data;
  if (strlen(message) > 4 && strncasecmp(message,"DONE",4)==0) {
    return 0;
  } else if (strlen(message) > 0) {
    dbmail_imap_session_buff_printf(self,"%s BAD Expecting DONE\r\n",
self->tag);
    dbmail_imap_session_buff_flush(self);
  }
  g_free(D->data);
  g_free(D);
} else {
....

I think not deleting D->data and D if message == "DONE" is the problem. 

---------------------------------------------------------------------- 
 (0002833) maximP (reporter) - 17-Jul-09 16:42
 http://dbmail.org/mantis/view.php?id=787#c2833 
---------------------------------------------------------------------- 
Looks like this patch solves the problem.

--- imapcommands.c.orig 2009-06-28 17:48:24.000000000 +0400
+++ imapcommands.c      2009-07-17 18:15:52.000000000 +0400
@@ -1085,6 +1085,8 @@
                        dm_thread_data *D = (gpointer)data;
                        message = (char *)D->data;
                        if (strlen(message) > 4 &&
strncasecmp(message,"DONE",4)==0) {
+                               g_free(D->data);
+                               g_free(D);
                                return 0;
                        } else if (strlen(message) > 0) {
                                dbmail_imap_session_buff_printf(self,"%s
BAD Expecting DONE\r\n", self->tag); 

---------------------------------------------------------------------- 
 (0002834) paul (administrator) - 17-Jul-09 22:41
 http://dbmail.org/mantis/view.php?id=787#c2834 
---------------------------------------------------------------------- 
Thanks again Maxim. 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
15-Jul-09 09:33  maximP         New Issue                                    
15-Jul-09 09:55  maximP         Note Added: 0002830                          
17-Jul-09 13:37  maximP         Note Added: 0002831                          
17-Jul-09 13:53  maximP         Note Added: 0002832                          
17-Jul-09 16:42  maximP         Note Added: 0002833                          
17-Jul-09 22:41  paul           Note Added: 0002834                          
17-Jul-09 22:42  paul           Assigned To               => paul            
17-Jul-09 22:42  paul           Status                   new => resolved     
17-Jul-09 22:42  paul           Resolution               open => fixed       
======================================================================

_______________________________________________
Dbmail-dev mailing list
Dbmail-dev@dbmail.org
http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail-dev

Reply via email to