Ok, some more info now. With the message attached to this bug report, if I break in nsMsgDBFolder::EndNewOfflineMessage() then I see the following: Breakpoint 9, nsMsgDBFolder::EndNewOfflineMessage (this=0x7fffca4bb400) at /home/chr1s/src/thunderbird/comm-central/mailnews/base/util/nsMsgDBFolder.cpp:1719 1719 mDatabase->MarkOffline(messageKey, false, nullptr); (gdb) p messageSize $15 = 4294959567 (gdb) p m_numOfflineMsgLines $16 = 11791 (gdb) p m_bytesAddedToLocalMsg $17 = 83 (gdb) p curStorePos $18 = 731268 (gdb) p messageSize + m_numOfflineMsgLines - m_bytesAddedToLocalMsg $19 = 3979 (gdb) t 22 [Switching to thread 22 (Thread 0x7fffc9dff700 (LWP 22310))] #0 pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:162 162 ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: No such file or directory. (gdb) f 7 #7 0x00007ffff30fb7b1 in nsImapProtocol::NormalMessageEndDownload (this=0x7fffcabae000) at /home/chr1s/src/thunderbird/comm-central/mailnews/imap/src/nsImapProtocol.cpp:3941 3941 m_imapMessageSink->NormalEndMsgWriteStream(m_downloadLineCache->CurrentUID(), imapAction == nsIImapUrl::nsImapMsgFetch, m_runningUrl, updatedMessageSize); (gdb) p m_bytesToChannel $20 = 731185 (gdb) p m_parser.fSizeOfMostRecentMessage $21 = 731185 So, the amount of data downloaded matches the size from the server (731185), but doesn't match the size stored in the summary file (3979). Running with NSPR_LOG_MODULES="imap:5,ImapAutoSync:5,mime:5,mgsdb:5,timestamp,sync", I see this logged (uninteresting bits removed): 2012-10-24 17:37:28.538382 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:SendData: 9 UID fetch 2:3 (UID X-GM-MSGID X-GM-THRID X-GM-LABELS RFC822.SIZE FLAGS BODY.PEEK[HEADER.FIELDS (From To Cc Bcc Subject Date Message-ID Priority X-Priority References Newsgroups In-Reply-To Content-Type List-id X-Bugzilla-URL X-Launchpad-Bug X-Generated-By X-Launchpad-Message-Rationale X-Launchpad-Build-State)]) 2012-10-24 17:37:28.588550 UTC - -908069120[7fffca734150]: ReadNextLine [stream=ca7fb3a0 nb=370 needmore=0] 2012-10-24 17:37:28.588614 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:CreateNewLineFromSocket: * 1 FETCH (X-GM-THRID 1416729568466002411 X-GM-MSGID 1416729568466002411 X-GM-LABELS () UID 2 RFC822.SIZE 731185 FLAGS (\Seen) BODY[HEADER.FIELDS (From To Cc Bcc Subject Date Message-ID Priority X-Priority References Newsgroups In-Reply-To Content-Type List-id X-Bugzilla-URL X-Launchpad-Bug X-Generated-By X-Launchpad-Message-Rationale X-Launchpad-Build-State)] {357} 2012-10-24 17:37:28.596380 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:STREAM:OPEN Size: 731185: Begin Message Download Stream ** snip ** 2012-10-24 17:37:31.973178 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:SendData: 12 UID fetch 2 (BODYSTRUCTURE) 2012-10-24 17:37:32.030042 UTC - -908069120[7fffca734150]: ReadNextLine [stream=ca7fb3a0 nb=291 needmore=0] 2012-10-24 17:37:32.030089 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:CreateNewLineFromSocket: * 1 FETCH (UID 2 BODYSTRUCTURE (("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 0 0 NIL NIL NIL)("APPLICATION" "MSWORD" ("NAME" "UNITED") NIL NIL "BASE64" 727294 NIL ("ATTACHMENT" ("FILENAME" "UNITED KINGDOM.doc")) NIL) "MIXED" ("BOUNDARY" "0-1859073355-1331973544=:13772") NIL NIL)) 2012-10-24 17:37:32.031068 UTC - -908069120[7fffca734150]: ReadNextLine [stream=ca7fb3a0 nb=15 needmore=0] 2012-10-24 17:37:32.031085 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:CreateNewLineFromSocket: 12 OK Success ** snip ** 2012-10-24 17:37:32.031136 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:SendData: 13 UID fetch 2 (BODY.PEEK[HEADER] BODY.PEEK[1.MIME] BODY.PEEK[2.MIME]) 2012-10-24 17:37:32.080690 UTC - -908069120[7fffca734150]: ReadNextLine [stream=ca7fb3a0 nb=38 needmore=0] 2012-10-24 17:37:32.080724 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:CreateNewLineFromSocket: * 1 FETCH (UID 2 BODY[HEADER] {3611} 2012-10-24 17:37:32.080753 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:STREAM:OPEN Size: 0: Begin Message Download Stream ** snip ** 2012-10-24 17:37:32.081880 UTC - -908069120[7fffca734150]: ReadNextLine [stream=ca7fb3a0 nb=15 needmore=0] 2012-10-24 17:37:32.081888 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:CreateNewLineFromSocket: 13 OK Success 2012-10-24 17:37:32.081928 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:STREAM:OPEN Size: 3969: Begin Message Download Stream 2012-10-24 17:37:32.081970 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:SHELL:GENERATE-MessageRFC822: 0 2012-10-24 17:37:32.081981 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:SHELL:GENERATE-MessageHeaders: 0 2012-10-24 17:37:32.081988 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:SHELL:GENERATE-Part-Prefetched: 0 2012-10-24 17:37:32.082006 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:SHELL:GENERATE-Multipart: 0 2012-10-24 17:37:32.082015 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:SHELL:GENERATE-Boundary: 0 2012-10-24 17:37:32.082026 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:SHELL:GENERATE-Leaf: 1 2012-10-24 17:37:32.082034 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:SHELL:GENERATE-MIMEHeader: 1 2012-10-24 17:37:32.082045 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:SHELL:GENERATE-Part-Inline: 1 2012-10-24 17:37:32.082052 UTC - -908069120[7fffca734150]: FetchTryChunking: curFetchSize 0 2012-10-24 17:37:32.082072 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:SendData: 14 UID fetch 2 (BODY.PEEK[1]) 2012-10-24 17:37:32.232584 UTC - -908069120[7fffca734150]: ReadNextLine [stream=ca7fb3a0 nb=30 needmore=0] 2012-10-24 17:37:32.232631 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:CreateNewLineFromSocket: * 1 FETCH (UID 2 BODY[1] {0} 2012-10-24 17:37:32.232662 UTC - -908069120[7fffca734150]: PARSER: fetch_literal chunk = 0, requested 0, receiving 0 2012-10-24 17:37:32.232674 UTC - -908069120[7fffca734150]: ReadNextLine [stream=ca7fb3a0 nb=3 needmore=0] 2012-10-24 17:37:32.232681 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:CreateNewLineFromSocket: ) 2012-10-24 17:37:32.232692 UTC - -908069120[7fffca734150]: ReadNextLine [stream=ca7fb3a0 nb=15 needmore=0] 2012-10-24 17:37:32.232698 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:CreateNewLineFromSocket: 14 OK Success 2012-10-24 17:37:32.232715 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:SHELL:GENERATE-Boundary: 0 2012-10-24 17:37:32.232733 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:SHELL:GENERATE-Leaf: 2 2012-10-24 17:37:32.232747 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:SHELL:GENERATE-XHeader: 2 2012-10-24 17:37:32.232753 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:SHELL:GENERATE-MIMEHeader: 2 2012-10-24 17:37:32.232759 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:SHELL:GENERATE-Filling: 2 2012-10-24 17:37:32.232766 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:SHELL:GENERATE-Boundary-Last: 0 2012-10-24 17:37:32.232773 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:STREAM:CLOSE: Normal Message End Download Stream 2012-10-24 17:37:32.255161 UTC - -134432960[7ffff6c17480]: 2012-10-24 17:37:32.255193 UTC - -134432960[7ffff6c17480]: 2012-10-24 17:37:32.255199 UTC - -134432960[7ffff6c17480]: 2012-10-24 17:37:32.255203 UTC - -134432960[7ffff6c17480]: 2012-10-24 17:37:32.255210 UTC - -134432960[7ffff6c17480]: MICROSOFT LOTTERY VIEW ATTACHMENT FOR DETAILS. 2012-10-24 17:37:32.255215 UTC - -134432960[7ffff6c17480]: 2012-10-24 17:37:32.255219 UTC - -134432960[7ffff6c17480]: 2012-10-24 17:37:32.255224 UTC - -134432960[7ffff6c17480]: 2012-10-24 17:37:32.255228 UTC - -134432960[7ffff6c17480]: 2012-10-24 17:37:32.255232 UTC - -134432960[7ffff6c17480]: 2012-10-24 17:37:32.255236 UTC - -134432960[7ffff6c17480]: 2012-10-24 17:37:32.255247 UTC - -134432960[7ffff6c17480]: 2012-10-24 17:37:32.273329 UTC - -134432960[7ffff6c17480]:
2012-10-24 17:37:32.273406 UTC - -134432960[7ffff6c17480]: 
2012-10-24 17:37:32.273419 UTC - -134432960[7ffff6c17480]:
2012-10-24 17:37:32.273534 UTC - -908069120[7fffca734150]: WARNING: Server's RFC822.SIZE 0 actual size 3979: file /home/chr1s/src/thunderbird/comm-central/mailnews/imap/src/nsImapProtocol.cpp, line 3932 2012-10-24 17:37:32.275002 UTC - -134432960[7ffff6c17480]: Updating stored message size from 731185, new size 3979 .....oooooooh :) then... 2012-10-24 17:37:36.000688 UTC - -908069120[7fffca734150]: FetchTryChunking: curFetchSize 3979 2012-10-24 17:37:36.000737 UTC - -908069120[7fffca734150]: FetchMessage peek: curFetchSize 3979 numBytes 0 2012-10-24 17:37:36.000756 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:SendData: 16 UID fetch 2 (UID RFC822.SIZE BODY.PEEK[]) 2012-10-24 17:37:36.220844 UTC - -908069120[7fffca734150]: ReadNextLine [stream=ca7fb3a0 nb=53 needmore=0] 2012-10-24 17:37:36.220900 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:CreateNewLineFromSocket: * 1 FETCH (UID 2 RFC822.SIZE 731185 BODY[] {731185} 2012-10-24 17:37:36.221291 UTC - -908069120[7fffca734150]: ca2bd800:imap.googlemail.com:S-[Google Mail]/Test:STREAM:OPEN Size: 731185: Begin Message Download Stream 2012-10-24 17:37:36.221349 UTC - -908069120[7fffca734150]: PARSER: fetch_literal chunk = 0, requested 3979, receiving 731185 Sorry for the braindump :)