Closed Bug 523114 Opened 15 years ago Closed 15 years ago

reindex crash [@ nsImapMailFolder::ParseAdoptedMsgLine(char const*, unsigned int, int, nsIImapUrl*)]


(MailNews Core :: Backend, defect)

1.9.1 Branch
Not set


(Not tracked)

Thunderbird 3.0rc1


(Reporter: wsmwk, Assigned: rkent)


(Keywords: crash, fixed-seamonkey2.0.1, qawanted)

Crash Data


(1 file, 1 obsolete file)

from crash-stats (not my crash)
reindex crash [@ nsImapMailFolder::ParseAdoptedMsgLine(char const*, unsigned int, int, nsIImapUrl*)]

top of stack is a topcrash for 3.0bpre - however, there may be at least two different crashes here based on cursory look at stacks, so we need to sort this out. marking blocking? just for the QA bit. I've dropped this into backend, rather than imap because reindex is mentioned in comments

nsImapMailFolder::ParseAdoptedMsgLine(char const*, unsigned int, int, nsIImapUrl*) is not new - goes back to at least 3.0b1

Rebuild index in imap inbox. I've had a message index problem today - one particular entry in the inbox list shows a completely different message when I click on the list item. I did two index rebuilds to try and correct it. The second one caused this crash.
Frame	Module	Signature [Expand]	Source
0	thunderbird-bin	nsImapMailFolder::ParseAdoptedMsgLine	mailnews/imap/src/nsImapMailFolder.cpp:4410
1	libxpcom_core.dylib	NS_InvokeByIndex_P	xpcom/reflect/xptcall/src/md/unix/xptcinvoke_unixish_x86.cpp:179
2	libxpcom_core.dylib	nsProxyObjectCallInfo::Run	xpcom/proxy/src/nsProxyEvent.cpp:181
3	libxpcom_core.dylib	nsThread::ProcessNextEvent	xpcom/threads/nsThread.cpp:521
4	libxpcom_core.dylib	NS_ProcessNextEvent_P	nsThreadUtils.cpp:227
5	thunderbird-bin	nsXULWindow::ShowModal	
6	thunderbird-bin	nsWindowWatcher::OpenWindowJSInternal	embedding/components/windowwatcher/src/nsWindowWatcher.cpp:992
7	thunderbird-bin	nsWindowWatcher::OpenWindowJS	embedding/components/windowwatcher/src/nsWindowWatcher.cpp:487
8	thunderbird-bin	nsGlobalWindow::OpenInternal	dom/src/base/nsGlobalWindow.cpp:7364
9	thunderbird-bin	nsGlobalWindow::OpenDialog	dom/src/base/nsGlobalWindow.cpp:5157
10	libxpcom_core.dylib	NS_InvokeByIndex_P	xpcom/reflect/xptcall/src/md/unix/xptcinvoke_unixish_x86.cpp:179
11	thunderbird-bin	XPCWrappedNative::CallMethod	js/src/xpconnect/src/xpcwrappednative.cpp:2456
12	thunderbird-bin	XPC_WN_CallMethod	js/src/xpconnect/src/xpcwrappednativejsops.cpp:1590
13	libmozjs.dylib	js_Invoke	js/src/jsinterp.cpp:1386
14	libmozjs.dylib	js_Interpret	js/src/jsinterp.cpp:5179
15	libmozjs.dylib	js_Invoke	js/src/jsinterp.cpp:1394
16	libmozjs.dylib	js_InternalInvoke	js/src/jsinterp.cpp:1447
17	libmozjs.dylib	JS_CallFunctionValue	js/src/jsapi.cpp:5187
18	thunderbird-bin	nsJSContext::CallEventHandler	dom/src/base/nsJSEnvironment.cpp:2085
19	thunderbird-bin	nsJSEventListener::HandleEvent	dom/src/events/nsJSEventListener.cpp:247
20	thunderbird-bin	nsEventListenerManager::HandleEventSubType	content/events/src/nsEventListenerManager.cpp:1098
21	thunderbird-bin	nsEventListenerManager::HandleEvent	content/events/src/nsEventListenerManager.cpp:1206
22	thunderbird-bin	nsEventTargetChainItem::HandleEvent	content/events/src/nsEventDispatcher.cpp:236 

a different crash
0	thunderbird.exe	nsMIMEHeaderParamImpl::GetParameterInternal	 netwerk/mime/src/nsMIMEHeaderParamImpl.cpp:210
1	thunderbird.exe	MimeHeaders_get_parameter	mailnews/mime/src/mimehdrs.cpp:492
2	thunderbird.exe	MimeMultipart_parse_line	mailnews/mime/src/mimemult.cpp:376
3	thunderbird.exe	convert_and_send_buffer	mailnews/mime/src/mimebuf.cpp:184
4	thunderbird.exe	mime_LineBuffer	mailnews/mime/src/mimebuf.cpp:272
5	thunderbird.exe	MimeObject_parse_buffer	mailnews/mime/src/mimeobj.cpp:275
6	thunderbird.exe	MimeMessage_parse_line	mailnews/mime/src/mimemsg.cpp:232
7	thunderbird.exe	convert_and_send_buffer	mailnews/mime/src/mimebuf.cpp:184
8	thunderbird.exe	mime_LineBuffer	mailnews/mime/src/mimebuf.cpp:272
9	thunderbird.exe	MimeObject_parse_buffer	mailnews/mime/src/mimeobj.cpp:275
10	thunderbird.exe	mime_display_stream_write	mailnews/mime/src/mimemoz2.cpp:946
11	thunderbird.exe	nsStreamConverter::OnDataAvailable	mailnews/mime/src/nsStreamConverter.cpp:938
12	thunderbird.exe	nsImapCacheStreamListener::OnDataAvailable	mailnews/imap/src/nsImapProtocol.cpp:8130
13	thunderbird.exe	nsInputStreamPump::OnStateTransfer	netwerk/base/src/nsInputStreamPump.cpp:508
14	thunderbird.exe	nsInputStreamPump::OnInputStreamReady	netwerk/base/src/nsInputStreamPump.cpp:398
15	xpcom_core.dll	nsOutputStreamReadyEvent::Run	xpcom/io/nsStreamUtils.cpp:111
Flags: blocking-thunderbird3?
If this upstream code at :

  if (err == NS_OK && m_mdbStore /* && hasOid */)

had err == NS_OK but null m_mdbStore, then in the code involved in the crash:

4407   if (!m_offlineHeader)
4408   {
4409     rv = GetMessageHeader(uidOfMessage, getter_AddRefs(m_offlineHeader));
4410     NS_ENSURE_SUCCESS(rv, rv);
4411     rv = StartNewOfflineMessage();
4412     m_offlineHeader->SetMessageSize(aMsgSize);
4413   }

(crash occurs at line 4412) the NS_ENSURE_SUCCESS would succeed, but with null m_offlineHeader. The defensive fix would be to add a null check for m_offlineHeader as well.

I'll do a patch and let bienvenu think about it.
Assignee: nobody → kent
What about making GetMessgeHeader return an error if m_mdbStore is null?
(In reply to comment #2)
> What about making GetMessgeHeader return an error if m_mdbStore is null?

I could go either way. Your proposal is a better fix, but a riskier fix, in that it a) assumes my analysis of the upstream source is correct, and b) assumes that no existing users of the code rely on the existing behaviour.
This is a conservative patch, that adds the check both in the place upstream where we think the error starts, and also near the crash. I could be persuaded to eliminate one of these checks, though I don't see the harm in doing both.
Attachment #407116 - Flags: superreview?(bienvenu)
Attachment #407116 - Flags: review?(bienvenu)
Comment on attachment 407116 [details] [diff] [review]
Rev a: add check in both folder and database code

I'd move the m_mdbStore check up here:

  if (!pmsgHdr || !m_mdbAllMsgHeadersTable)

any header we return from the use cache w/ a null mdbstore is going to be dangerous.

I had actually suggested changing GetMessageHeader, which is at a bit higher level, and thus potentially less risky. But I'm OK with changing GetMsgHdrForKey if you move the m_mdbStore check higher up.
Whiteboard: [has patch for review, needs tweaking]
Flags: blocking-thunderbird3? → blocking-thunderbird3+
Attachment #407116 - Attachment is obsolete: true
Attachment #407300 - Flags: superreview?(bienvenu)
Attachment #407300 - Flags: review?(bienvenu)
Attachment #407116 - Flags: superreview?(bienvenu)
Attachment #407116 - Flags: review?(bienvenu)
Comment on attachment 407300 [details] [diff] [review]
Rev b: move check earlier in GetMsgHdrForKey

thx, Kent.
Attachment #407300 - Flags: superreview?(bienvenu)
Attachment #407300 - Flags: superreview+
Attachment #407300 - Flags: review?(bienvenu)
Attachment #407300 - Flags: review+
Whiteboard: [has patch for review, needs tweaking] → [ready to land]
fix checked in.
Closed: 15 years ago
Resolution: --- → FIXED
Whiteboard: [ready to land]
Target Milestone: --- → Thunderbird 3.0rc1
Crash Signature: [@ nsImapMailFolder::ParseAdoptedMsgLine(char const*, unsigned int, int, nsIImapUrl*)]
You need to log in before you can comment on or make changes to this bug.