[Dovecot] Debugging msync() failed errors

Timo Sirainen tss at iki.fi
Thu Jan 6 21:24:32 EET 2005


On Tue, 2004-12-28 at 10:05 -0800, Doug Luce wrote:
> >From today's maillog:
> 
> maillog:Dec 28 09:49:10 aurora dovecot: IMAP(doug): msync() failed with index file /home/doug/Maildir/dovecot.index: Invalid argument
> 
> Can anyone slip me some advice on how to properly go about debugging
> this problem?  Is there a way to check the .index file?  Can anyone
> make an educated guess as to what section of code is the likely
> culprit?

There are only two msync() calls in the code. Try what it says with this
patch:

Index: src/lib-index/mail-index-sync-update.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-sync-update.c,v
retrieving revision 1.78
diff -u -r1.78 mail-index-sync-update.c
--- src/lib-index/mail-index-sync-update.c	26 Dec 2004 09:12:40 -0000	1.78
+++ src/lib-index/mail-index-sync-update.c	6 Jan 2005 19:23:55 -0000
@@ -675,6 +675,14 @@
 		       PTR_OFFSET(map->hdr_base, sizeof(map->hdr)),
 		       map->hdr.header_size - sizeof(map->hdr));
 		if (msync(map->mmap_base, map->mmap_used_size, MS_SYNC) < 0) {
+			void *p;
+			i_error("msync(%p, %"PRIuSIZE_T") failed, checking..",
+				map->mmap_base, map->mmap_used_size);
+			p = i_malloc(map->mmap_used_size);
+			memcpy(p, map->mmap_base, map->mmap_used_size);
+			i_free(p);
+			i_error("we didn't crash, the address range is ok.");
+
 			mail_index_set_syscall_error(index, "msync()");
 			ret = -1;
 		}
Index: src/lib-index/mail-index.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.184
diff -u -r1.184 mail-index.c
--- src/lib-index/mail-index.c	26 Dec 2004 09:12:40 -0000	1.184
+++ src/lib-index/mail-index.c	6 Jan 2005 19:23:56 -0000
@@ -1057,8 +1057,12 @@
 
 	if (!MAIL_INDEX_MAP_IS_IN_MEMORY(index->map)) {
 		memcpy(index->map->mmap_base, hdr, hdr_size);
-		if (msync(index->map->mmap_base, hdr_size, MS_SYNC) < 0)
+		if (msync(index->map->mmap_base, hdr_size, MS_SYNC) < 0) {
+			i_error("header: msync(%p, %"PRIuSIZE_T") failed, mmap_size=%"PRIuSIZE_T,
+				index->map->mmap_base, hdr_size,
+				index->map->mmap_size);
 			return mail_index_set_syscall_error(index, "msync()");
+		}
 	} else {
 		if (pwrite_full(index->fd, hdr, hdr_size, 0) < 0) {
 			mail_index_set_syscall_error(index, "pwrite_full()");

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://dovecot.org/pipermail/dovecot/attachments/20050106/a4d32965/attachment-0001.bin>


More information about the dovecot mailing list