Closed Bug 489993 Opened 15 years ago Closed 15 years ago

click folder virtual hang [@ nsMsgXFVirtualFolderDBView::UpdateCacheAndViewForPrevSearchedFolders] high cpu

Categories

(MailNews Core :: Backend, defect)

x86
Windows XP
defect
Not set
critical

Tracking

(Not tracked)

VERIFIED FIXED
Thunderbird 3.0b3

People

(Reporter: wsmwk, Assigned: Bienvenu)

Details

(Keywords: hang)

Attachments

(2 files)

Attached image snap of visual studio
20090423 build windows XP

1. TB as top window application in an unfocused remote desktop session, with some folder X selected in account A
2. click "cas1" folder in account B focusing both the RDP session and TB

high cpu hang

stack from Visual studio...

>	thunderbird.exe!nsMsgXFVirtualFolderDBView::UpdateCacheAndViewForPrevSearchedFolders(nsIMsgFolder * curSearchFolder=0x0498bac0)  Line 266 + 0x8 bytes	C++
 	thunderbird.exe!nsMsgXFVirtualFolderDBView::OnSearchHit(nsIMsgDBHdr * aMsgHdr=0x0cad9b00, nsIMsgFolder * aFolder=0x04a440c0)  Line 301	C++
 	thunderbird.exe!nsMsgSearchSession::AddSearchHit(nsIMsgDBHdr * aHeader=0x0cad9b00, nsIMsgFolder * aFolder=0x0498bac0)  Line 580 + 0xf bytes	C++
 	thunderbird.exe!nsMsgSearchOnlineMail::AddResultElement(nsIMsgDBHdr * pHeaders=0x0cad9b00)  Line 96	C++
 	thunderbird.exe!nsMsgSearchOfflineMail::Search(int * aDone=0x0012fc1c)  Line 758	C++
 	thunderbird.exe!nsMsgSearchScopeTerm::TimeSlice(int * aDone=0x0012fc1c)  Line 1797	C++
 	thunderbird.exe!nsMsgSearchSession::TimeSliceSerial(int * aDone=0x0012fc1c)  Line 692 + 0x8 bytes	C++
 	thunderbird.exe!nsMsgSearchSession::TimerCallback(nsITimer * aTimer=0x0793a700, void * aClosure=0x089ae2e0)  Line 526	C++
 	xpcom_core.dll!nsTimerImpl::Fire()  Line 420 + 0x6 bytes	C++
 	xpcom_core.dll!nsTimerEvent::Run()  Line 514	C++
 	xpcom_core.dll!nsThread::ProcessNextEvent(int mayWait=1, int * result=0x0012fc80)  Line 511	C++
 	xpcom_core.dll!NS_ProcessNextEvent_P(nsIThread * thread=0x00000001, int mayWait=1)  Line 227 + 0xd bytes	C++
 	thunderbird.exe!nsBaseAppShell::Run()  Line 170 + 0x9 bytes	C++
 	thunderbird.exe!nsAppStartup::Run()  Line 194	C++
 	thunderbird.exe!XRE_main(int argc=1, char * * argv=0x01811090, const nsXREAppData * aAppData=0x01815340)  Line 3300	C++
 	thunderbird.exe!NS_internal_main(int argc=1, char * * argv=0x01811090)  Line 104	C++
 	thunderbird.exe!wmain(int argc=25235600, wchar_t * * argv=0x01824780)  Line 112	C++
 	thunderbird.exe!__tmainCRTStartup()  Line 591 + 0x19 bytes	C
 	kernel32.dll!_BaseProcessStart@4()  + 0x23 bytes	

and about 21 threads like ...
 	ntdll.dll!_KiFastSystemCallRet@0() 	
 	ntdll.dll!_ZwWaitForSingleObject@12()  + 0xc bytes	
 	kernel32.dll!_WaitForSingleObjectEx@12()  + 0x8b bytes	
 	kernel32.dll!_WaitForSingleObject@8()  + 0x12 bytes	
 	nspr4.dll!_PR_MD_WAIT_CV(_MDCVar * cv=0x01991334, _MDLock * lock=0x0187856c, unsigned int timeout=1000)  Line 282	C
 	nspr4.dll!_PR_WaitCondVar(PRThread * thread=0x01831280, PRCondVar * cvar=0x019912c0, PRLock * lock=0x01878550, unsigned int timeout=1000)  Line 205	C
 	nspr4.dll!PR_WaitCondVar(PRCondVar * cvar=0x019912c0, unsigned int timeout=1000)  Line 551 + 0xd bytes	C
 	thunderbird.exe!XPCJSRuntime::WatchdogMain(void * arg=0x0198b000)  Line 828	C++
 	nspr4.dll!_PR_NativeRunThread(void * arg=0x01983460)  Line 458	C
 	nspr4.dll!pr_root(void * arg=0x01831280)  Line 122 + 0xd bytes	C
>	mozcrt19.dll!_callthreadstartex()  Line 348 + 0x9 bytes	C
 	mozcrt19.dll!_threadstartex(void * ptd=0x01950800)  Line 326 + 0x5 bytes	C
 	kernel32.dll!_BaseThreadStart@8()  + 0x37 bytes
note: folder clicked, cas1, was not a virtual folder


actually most of the _callthreadstartex threads have imap info and look like
 	ntdll.dll!_KiFastSystemCallRet@0() 	
 	ntdll.dll!_ZwWaitForSingleObject@12()  + 0xc bytes	
 	kernel32.dll!_WaitForSingleObjectEx@12()  + 0x8b bytes	
 	kernel32.dll!_WaitForSingleObject@8()  + 0x12 bytes	
 	nspr4.dll!_PR_MD_WAIT_CV(_MDCVar * cv=0x079bfda4, _MDLock * lock=0x079bfcbc, unsigned int timeout=4294967295)  Line 282	C
 	nspr4.dll!_PR_WaitCondVar(PRThread * thread=0x03b78b40, PRCondVar * cvar=0x079bfd30, PRLock * lock=0x079bfca0, unsigned int timeout=4294967295)  Line 205	C
 	nspr4.dll!PR_Wait(PRMonitor * mon=0x0d08e100, unsigned int ticks=4294967295)  Line 175 + 0x1a bytes	C
 	xpcom_core.dll!nsEventQueue::GetEvent(int mayWait=1, nsIRunnable * * result=0x0587fd44)  Line 85 + 0x9 bytes	C++
 	xpcom_core.dll!nsThread::ProcessNextEvent(int mayWait=1, int * result=0x0587fd64)  Line 503	C++
 	xpcom_core.dll!NS_ProcessNextEvent_P(nsIThread * thread=0x045a4f10, int mayWait=1)  Line 227 + 0xd bytes	C++
 	xpcom_core.dll!nsProxyEventObject::CallMethod(unsigned short methodIndex=20288, const XPTMethodDescriptor * methodInfo=0x045a4f10, nsXPTCMiniVariant * params=0x0dce4198)  Line 260 + 0xa bytes	C++
 	xpcom_core.dll!PrepareAndDispatch(nsXPTCStubBase * self=0x043ec4e0, unsigned int methodIndex=18, unsigned int * args=0x0587fe5c, unsigned int * stackBytesToPop=0x0587fe4c)  Line 114 + 0x15 bytes	C++
 	xpcom_core.dll!SharedStub()  Line 142	C++
 	thunderbird.exe!nsImapProtocol::HandleIdleResponses()  Line 1399	C++
 	thunderbird.exe!nsImapProtocol::HandleIdleResponses()  Line 1399	C++
 	thunderbird.exe!nsImapProtocol::ImapThreadMainLoop()  Line 1369	C++
 	thunderbird.exe!nsImapProtocol::Run()  Line 1051	C++
 	xpcom_core.dll!nsThread::ProcessNextEvent(int mayWait=1, int * result=0x0587ff30)  Line 511	C++
 	xpcom_core.dll!NS_ProcessNextEvent_P(nsIThread * thread=0x00000001, int mayWait=1)  Line 227 + 0xd bytes	C++
 	xpcom_core.dll!nsThread::ThreadFunc(void * arg=0x045a4f10)  Line 254 + 0x8 bytes	C++
 	nspr4.dll!_PR_NativeRunThread(void * arg=0x03b92e80)  Line 458	C
 	nspr4.dll!pr_root(void * arg=0x03b78b40)  Line 122 + 0xd bytes	C
>	mozcrt19.dll!_callthreadstartex()  Line 348 + 0x9 bytes	C
 	mozcrt19.dll!_threadstartex(void * ptd=0x043a9400)  Line 326 + 0x5 bytes	C
 	kernel32.dll!_BaseThreadStart@8()  + 0x37 bytes
cas1 is a virtual folder.
the folder displayed, and best guess (until I restart TB to see for sure) is the results shown are accurate

a few break points in VS show ....

009C7FF4  je          nsMsgXFVirtualFolderDBView::UpdateCacheAndViewForPrevSearchedFolders+0BDh (9C8010h) 
009C7FF6  cmp         eax,dword ptr [esi+248h] 

009C7FDF  je          nsMsgXFVirtualFolderDBView::UpdateCacheAndViewForPrevSearchedFolders+93h (9C7FE6h) 
009C7FE1  mov         eax,dword ptr [eax+4] 

009C7FF4  je          nsMsgXFVirtualFolderDBView::UpdateCacheAndViewForPrevSearchedFolders+0BDh (9C8010h) 

009C7FEA  jle         nsMsgXFVirtualFolderDBView::UpdateCacheAndViewForPrevSearchedFolders+0CCh (9C801Fh) 
009C7FEC  mov         eax,dword ptr [edi] 
009C7FF6  cmp         eax,dword ptr [esi+248h]
Summary: click folder hang [@ nsMsgXFVirtualFolderDBView::UpdateCacheAndViewForPrevSearchedFolders] → click folder virtual hang [@ nsMsgXFVirtualFolderDBView::UpdateCacheAndViewForPrevSearchedFolders]
repro - click on cas1 folder results again in hang.
I can click other folders, and saved searches in this account.

I can do r-click and do "properties" on this saved search and access all the real folders it accesses, and exit properties without hanging. "search online" is checked on.

windbg !analyze -hang -v  results ...

EXCEPTION_RECORD:  ffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 7c90120e (ntdll!DbgBreakPoint)
   ExceptionCode: 80000003 (Break instruction exception)
  ExceptionFlags: 00000000
NumberParameters: 3
   Parameter[0]: 00000000
   Parameter[1]: 00000002
   Parameter[2]: 00000003

FAULTING_THREAD:  00000000

BUGCHECK_STR:  HANG

PROCESS_NAME:  thunderbird.exe

ERROR_CODE: (NTSTATUS) 0xcfffffff - <Unable to get error code text>

EXCEPTION_CODE: (NTSTATUS) 0xcfffffff - <Unable to get error code text>

EXCEPTION_PARAMETER1:  00000000

EXCEPTION_PARAMETER2:  00000002

EXCEPTION_PARAMETER3:  00000003

NTGLOBALFLAG:  0

APPLICATION_VERIFIER_FLAGS:  0

DERIVED_WAIT_CHAIN:  

Dl Eid Cid     WaitType
-- --- ------- --------------------------
   29  920.2c0 Speculated (Triage)    -->
   0   920.cd0 Unknown                

WAIT_CHAIN_COMMAND:  ~29s;k;;~0s;k;;

BLOCKING_THREAD:  00000cd0

DEFAULT_BUCKET_ID:  APPLICATION_HANG_BusyHang

PRIMARY_PROBLEM_CLASS:  APPLICATION_HANG_BusyHang

LAST_CONTROL_TRANSFER:  from 009c809d to 009c7ff6

STACK_TEXT:  
0012f9a4 009c809d 04203160 0816c550 00000000 thunderbird!nsMsgXFVirtualFolderDBView::UpdateCacheAndViewForPrevSearchedFolders+0xa3 [e:\builds\buildbot\comm-central-win32-nightly\build\mailnews\base\src\nsmsgxfvirtualfolderdbview.cpp @ 275]
0012f9d0 009a81f9 033d25c4 078d43d0 06ca5460 thunderbird!nsMsgXFVirtualFolderDBView::OnSearchHit+0x77 [e:\builds\buildbot\comm-central-win32-nightly\build\mailnews\base\src\nsmsgxfvirtualfolderdbview.cpp @ 301]
0012f9f0 00a80334 033d25c4 078d43d0 04203160 thunderbird!nsMsgSearchSession::AddSearchHit+0x4e [e:\builds\buildbot\comm-central-win32-nightly\build\mailnews\base\search\src\nsmsgsearchsession.cpp @ 580]
0012fa14 00a7f66c 04203160 078d43d0 0012fc1c thunderbird!nsMsgSearchOnlineMail::AddResultElement+0x52 [e:\builds\buildbot\comm-central-win32-nightly\build\mailnews\base\search\src\nsmsgimapsearch.cpp @ 96]
0012fbd8 009aa565 0816c550 0012fc1c 009a8087 thunderbird!nsMsgSearchOfflineMail::Search+0x1d5 [e:\builds\buildbot\comm-central-win32-nightly\build\mailnews\base\search\src\nsmsglocalsearch.cpp @ 758]
0012fbe4 009a8087 0012fc1c 00000000 07ef21a0 thunderbird!nsMsgSearchScopeTerm::TimeSlice+0xd [e:\builds\buildbot\comm-central-win32-nightly\build\mailnews\base\search\src\nsmsgsearchterm.cpp @ 1797]
0012fbfc 009a83c2 0012fc1c 009a83a7 0848c130 thunderbird!nsMsgSearchSession::TimeSliceSerial+0x26 [e:\builds\buildbot\comm-central-win32-nightly\build\mailnews\base\search\src\nsmsgsearchsession.cpp @ 692]
0012fc24 002dc195 0848c130 07ef21a0 00000000 thunderbird!nsMsgSearchSession::TimerCallback+0x1b [e:\builds\buildbot\comm-central-win32-nightly\build\mailnews\base\search\src\nsmsgsearchsession.cpp @ 526]
0012fc3c 002dc328 01814330 002dcabd 03022570 xpcom_core!nsTimerImpl::Fire+0x94 [e:\builds\buildbot\comm-central-win32-nightly\build\mozilla\xpcom\threads\nstimerimpl.cpp @ 420]
0012fc44 002dcabd 03022570 01814330 002eb742 xpcom_core!nsTimerEvent::Run+0x1b [e:\builds\buildbot\comm-central-win32-nightly\build\mozilla\xpcom\threads\nstimerimpl.cpp @ 514]
0012fc64 002b6238 00000001 00000001 0012fc80 xpcom_core!nsThread::ProcessNextEvent+0xc3 [e:\builds\buildbot\comm-central-win32-nightly\build\mozilla\xpcom\threads\nsthread.cpp @ 511]
0012fc78 0056148c 00000001 00000001 002b25e5 xpcom_core!NS_ProcessNextEvent_P+0x20 [e:\builds\buildbot\comm-central-win32-nightly\build\objdir-tb\mozilla\xpcom\build\nsthreadutils.cpp @ 227]
0012fc8c 008fa029 01952bc0 00000000 004060a8 thunderbird!nsBaseAppShell::Run+0x2a [e:\builds\buildbot\comm-central-win32-nightly\build\mozilla\widget\src\xpwidgets\nsbaseappshell.cpp @ 170]
0012fc98 004060a8 01960820 01821098 80000000 thunderbird!nsAppStartup::Run+0x1e [e:\builds\buildbot\comm-central-win32-nightly\build\mozilla\toolkit\components\startup\src\nsappstartup.cpp @ 194]
0012ff1c 0040125d 00000001 01821090 01813300 thunderbird!XRE_main+0x14a1 [e:\builds\buildbot\comm-central-win32-nightly\build\mozilla\toolkit\xre\nsapprunner.cpp @ 3300]
0012ff4c 0040135f 00000001 01821090 7c809842 thunderbird!NS_internal_main+0xbe [e:\builds\buildbot\comm-central-win32-nightly\build\mail\app\nsmailapp.cpp @ 104]
0012ff80 00b85382 01821090 0181f700 018110c0 thunderbird!wmain+0xf3 [e:\builds\buildbot\comm-central-win32-nightly\build\mozilla\toolkit\xre\nswindowswmain.cpp @ 112]
0012ffc0 7c817077 01a0dd60 7c90d96e 7ffde000 thunderbird!__tmainCRTStartup+0x152 [e:\builds\buildbot\comm-central-win32-nightly\build\objdir-tb\mozilla\memory\jemalloc\src\crtexe.c @ 591]
0012fff0 00000000 00b85500 00000000 78746341 kernel32!BaseProcessStart+0x23


FOLLOWUP_IP: 
thunderbird!nsMsgSearchSession::TimerCallback+1b [e:\builds\buildbot\comm-central-win32-nightly\build\mailnews\base\search\src\nsmsgsearchsession.cpp @ 526]
009a83c2 57              push    edi

FAULTING_SOURCE_CODE:  
No source found for 'e:\builds\buildbot\comm-central-win32-nightly\build\mailnews\base\search\src\nsmsgsearchsession.cpp'


SYMBOL_STACK_INDEX:  7

SYMBOL_NAME:  thunderbird!nsMsgSearchSession::TimerCallback+1b

FOLLOWUP_NAME:  MachineOwner

MODULE_NAME: thunderbird

IMAGE_NAME:  thunderbird.exe

DEBUG_FLR_IMAGE_TIMESTAMP:  49f055d4

STACK_COMMAND:  ~0s ; kb

BUCKET_ID:  HANG_thunderbird!nsMsgSearchSession::TimerCallback+1b

FAILURE_BUCKET_ID:  APPLICATION_HANG_BusyHang_cfffffff_thunderbird.exe!nsMsgSearchSession::TimerCallback

WATSON_STAGEONE_URL:  http://watson.microsoft.com/StageOne/thunderbird_exe/1_9_1_3400/49f055d4/ntdll_dll/5_1_2600_5755/49901d48/cfffffff/0000120e.htm?Retriage=1
Summary: click folder virtual hang [@ nsMsgXFVirtualFolderDBView::UpdateCacheAndViewForPrevSearchedFolders] → click folder virtual hang [@ nsMsgXFVirtualFolderDBView::UpdateCacheAndViewForPrevSearchedFolders] high cpu
So, slightly different scenario, but it would appear the same infinite loop problem and a similar fix, most likely...

If you interrupt an XFVF search almost immediately, it calls UpdateCacheAndViewForPrevSearchedFolders with curSearchFolder=nsnull.  The result is that the (m_foldersSearchingOver.Count() > 0) loop test always passes because the first case never matches (nsnull never == a real thing), and neither does the second case (m_foldersSearchingOver[0] will never != m_curFolderGettingHits).

I'm not sure what is harshing Wayne's case, but I think it's safe to say that a loop that does not guarantee termination is a bad loop.  The investigation should be able to figure out what is going wrong in the other case too.

Requesting blocking because with smart folders, XFVF's are now quite likely and an infinite loop is not cool.
Flags: blocking-thunderbird3?
yes, we should fix this. I suspect Wayne might have been seeing bug 489711, though I could be wrong.
Flags: blocking-thunderbird3? → blocking-thunderbird3+
Target Milestone: --- → Thunderbird 3.0b3
(In reply to comment #5)
> I suspect Wayne might have been seeing bug 489711

Nah - cas1 folder still hangs with 20090505 build + bug 489711
(perhaps unrelated, but this folder is very small - maybe 20 messages)
I'll work with Wayne to try to figure out what's going on here...
Assignee: nobody → bienvenu
Wayne, if you reproduce this, and get into the debugger, if you step out, are you looping inside OnSearchHit, or in repeated calls to OnSearchHit?
Attached patch possible fixSplinter Review
this makes sure that we remove folders that have gotten hits from m_foldersSearchingOver, so we can get rid of the test that was failing in the null curSearchFolder case, which should prevent infinite loops.
Attachment #377024 - Flags: superreview?(bugzilla)
Attachment #377024 - Flags: review?(bugmail)
Status: NEW → ASSIGNED
Whiteboard: [has patch, needs r asuth, sr standard]
Comment on attachment 377024 [details] [diff] [review]
possible fix

Hooray for loop termination.
Attachment #377024 - Flags: review?(bugmail) → review+
Attachment #377024 - Flags: superreview?(bugzilla) → superreview+
fix checked in, thx for the diagnosis, asuth. 

Wayne, let me know if this doesn't fix it for you...
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Whiteboard: [has patch, needs r asuth, sr standard]
no crash with Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1b5pre) Gecko/20090515 Shredder/3.0b3pre
v.fixed
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: