Bug: Daily hangs frequently from nsImapProtocol::LoadImapUrlInternal
Status: RESOLVED
Priority: P1
Resolution: FIXED
Created: 2023-02-14 10:28:00+00:00
Resolved: 2023-02-17 20:31:15+00:00

Daily has hung a couple times this week. I caught it with GDB and it seems like a bug in the imap code when called potentially reentrantly?

Main thread stack here (sorry, my window manager killed TB so I couldn't investigate much more):

```
(gdb) up
#1  0x00007fb73a09df90 in pthread_cond_wait () from /usr/lib/libc.so.6
(gdb) 
#2  0x000055ffc7efa17f in mozilla::detail::ConditionVariableImpl::wait(mozilla::detail::MutexImpl&) ()
(gdb) 
#3  0x00007fb72edc68f1 in mozilla::SyncRunnable::DispatchToThread(nsIEventTarget*, bool) () from /home/emilio/thunderbird/libxul.so
(gdb) 
#4  0x00007fb733190219 in nsImapProtocol::LoadImapUrlInternal() () from /home/emilio/thunderbird/libxul.so
(gdb) 
#5  0x00007fb73318f655 in nsImapProtocol::SetupWithUrl(nsIURI*, nsISupports*) () from /home/emilio/thunderbird/libxul.so
(gdb) 
#6  0x00007fb73319926a in nsImapProtocol::LoadImapUrl(nsIURI*, nsISupports*) () from /home/emilio/thunderbird/libxul.so
(gdb) 
#7  0x00007fb733156d63 in nsImapIncomingServer::LoadNextQueuedUrl(nsIImapProtocol*, bool*) () from /home/emilio/thunderbird/libxul.so
(gdb) 
#8  0x00007fb733156249 in nsImapIncomingServer::GetImapConnectionAndLoadUrl(nsIImapUrl*, nsISupports*) () from /home/emilio/thunderbird/libxul.so
(gdb) 
#9  0x00007fb7331b5794 in nsImapService::GetImapConnectionAndLoadUrl(nsIImapUrl*, nsISupports*, nsIURI**) () from /home/emilio/thunderbird/libxul.so
(gdb) 
#10 0x00007fb7331b9b8e in nsImapService::GetMessageFromUrl(nsIImapUrl*, int, nsIMsgFolder*, nsIImapMessageSink*, nsIMsgWindow*, nsISupports*, bool, nsIURI**) () from /home/emilio/thunderbird/libxul.so
(gdb) 
#11 0x00007fb7331b9630 in nsImapService::FetchMessage(nsIImapUrl*, int, nsIMsgFolder*, nsIImapMessageSink*, nsIMsgWindow*, nsISupports*, nsTSubstring<char> const&, bool, nsIURI**) () from /home/emilio/thunderbird/libxul.so
(gdb) 
#12 0x00007fb7331c1c12 in nsImapService::DownloadMessagesForOffline(nsTSubstring<char> const&, nsIMsgFolder*, nsIUrlListener*, nsIMsgWindow*) () from /home/emilio/thunderbird/libxul.so
(gdb) 
#13 0x00007fb73314f361 in nsAutoSyncState::DownloadMessagesForOffline(nsTArray<RefPtr<nsIMsgDBHdr> > const&) () from /home/emilio/thunderbird/libxul.so
(gdb) 
#14 0x00007fb73314a09c in nsAutoSyncManager::DownloadMessagesForOffline(nsIAutoSyncState*, unsigned int) () from /home/emilio/thunderbird/libxul.so
(gdb) 
#15 0x00007fb73314a38c in nsAutoSyncManager::HandleDownloadErrorFor(nsIAutoSyncState*, nsresult) () from /home/emilio/thunderbird/libxul.so
(gdb) 
#16 0x00007fb73314bed1 in nsAutoSyncManager::OnDownloadCompleted(nsIAutoSyncState*, nsresult) () from /home/emilio/thunderbird/libxul.so
(gdb) 
#17 0x00007fb73314e8b2 in nsAutoSyncState::OnStopRunningUrl(nsIURI*, nsresult) () from /home/emilio/thunderbird/libxul.so
(gdb) 
#18 0x00007fb73309ce0f in nsMsgMailNewsUrl::SetUrlState(bool, nsresult) () from /home/emilio/thunderbird/libxul.so
(gdb) 
#19 0x00007fb73317ce2d in nsImapMailFolder::SetUrlState(nsIImapProtocol*, nsIMsgMailNewsUrl*, bool, bool, nsresult) () from /home/emilio/thunderbird/libxul.so
(gdb) 
#20 0x00007fb7331d2463 in (anonymous namespace)::SyncRunnable5<nsIImapMailFolderSink, nsIImapProtocol*, nsIMsgMailNewsUrl*, bool, bool, nsresult>::Run() () from /home/emilio/thunderbird/libxul.so
(gdb) 
#21 0x00007fb72ed3d095 in mozilla::RunnableTask::Run() () from /home/emilio/thunderbird/libxul.so
(gdb) 
#22 0x00007fb72ed38de3 in mozilla::TaskController::DoExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) () from /home/emilio/thunderbird/libxul.so
(gdb) 
#23 0x00007fb72ed38049 in mozilla::TaskController::ExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) () from /home/emilio/thunderbird/libxul.so
(gdb) 
#24 0x00007fb72ed38298 in mozilla::TaskController::ProcessPendingMTTask(bool) () from /home/emilio/thunderbird/libxul.so
(gdb) 
#25 0x00007fb72ed3e9f2 in mozilla::detail::RunnableFunction<mozilla::TaskController::InitializeInternal()::$_2>::Run() () from /home/emilio/thunderbird/libxul.so
(gdb) 
#26 0x00007fb72ed4b997 in nsThread::ProcessNextEvent(bool, bool*) () from /home/emilio/thunderbird/libxul.so
(gdb) 
#27 0x00007fb72ed4f64c in NS_ProcessNextEvent(nsIThread*, bool) () from /home/emilio/thunderbird/libxul.so
```