Balsa hangs when expunging multiple erased IMAP messages
I noticed a reproducible hang when I delete multiple messages on a IMAP account, and then try to expunge them. Expunging typically works when I erase less than ~10 messages, but occurs always (afaict) when more shall be deleted.
I gdb
, Balsa hangs in libbalsa/imap/imap-commands.c
, line 1043, function imap_mbox_handle_fetch_range()
, whilst trying to lock the handle mutex (see the backtrace balsa-imap-hang.bt.gz):
g_mutex_lock(&handle->mutex);
It seems that the mutex has been locked in frame 33, function imap_mbox_expunge()
. This function, after a few steps, calls ir_expunge()
which in line 2635 fires the signal
g_signal_emit(h, imap_mbox_handle_signals[EXPUNGE_NOTIFY],
0, seqno);
which, through the signal handler, ultimately calls imap_mbox_handle_fetch_range()
.
Unfortunately, I'm not familiar with the IMAP state machine… @peterb or @pawels, do you have an idea how to resolve the issue?
BTW, there might to be more locking issues – e.g. the function
ImapResponse
imap_mbox_handle_fetch_set(ImapMboxHandle* handle,
unsigned *set, unsigned cnt, ImapFetchType ift)
{
ImapResponse rc;
g_mutex_lock(&handle->mutex);
rc = imap_mbox_handle_fetch_set_unlocked(handle, set, cnt, ift);
g_mutex_unlock(&handle->mutex);
return rc;
}
will unlock the mutex twice if the macro in imap_mbox_handle_fetch_set_unlocked()
, line 1075 fails:
IMAP_REQUIRED_STATE1(handle, IMHS_SELECTED, IMR_BAD);
expands to
do{if(!(handle) || handle->state != (IMHS_SELECTED)) \
{g_mutex_unlock(&handle->mutex); return (IMR_BAD);}}while(0);