[evolution] Fix a crash when filling mail threaded view
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Fix a crash when filling mail threaded view
- Date: Mon, 13 May 2019 16:26:35 +0000 (UTC)
commit 2dd75ea39b08fadf6f28c923b726488eef149398
Author: Milan Crha <mcrha redhat com>
Date: Mon May 13 18:23:12 2019 +0200
Fix a crash when filling mail threaded view
There could happen a crash when a folder received an update and it
had been shown in the message list in the threaded view. With a proper
thread interleaving the main thread could use the CamelFolderThread
structure, while another thread had been freeing its internal members.
The fix is to not re-use existing CamelFolderThread structure and always
build a new one. This makes the filling a bit quicker too.
Reported downstream at:
https://bugzilla.redhat.com/show_bug.cgi?id=1709367
src/mail/message-list.c | 34 ++++------------------------------
1 file changed, 4 insertions(+), 30 deletions(-)
---
diff --git a/src/mail/message-list.c b/src/mail/message-list.c
index ecf36b9a88..58fb1aea35 100644
--- a/src/mail/message-list.c
+++ b/src/mail/message-list.c
@@ -566,25 +566,6 @@ regen_data_unref (RegenData *regen_data)
}
}
-static CamelFolderThread *
-message_list_ref_thread_tree (MessageList *message_list)
-{
- CamelFolderThread *thread_tree = NULL;
-
- g_return_val_if_fail (IS_MESSAGE_LIST (message_list), NULL);
-
- g_mutex_lock (&message_list->priv->thread_tree_lock);
-
- if (message_list->priv->thread_tree != NULL) {
- thread_tree = message_list->priv->thread_tree;
- camel_folder_thread_messages_ref (thread_tree);
- }
-
- g_mutex_unlock (&message_list->priv->thread_tree_lock);
-
- return thread_tree;
-}
-
static void
message_list_set_thread_tree (MessageList *message_list,
CamelFolderThread *thread_tree)
@@ -6157,17 +6138,10 @@ message_list_regen_thread (GSimpleAsyncResult *simple,
if (regen_data->group_by_threads) {
CamelFolderThread *thread_tree;
- thread_tree = message_list_ref_thread_tree (message_list);
-
- if (thread_tree != NULL) {
- /* Make sure multiple threads will not access the same
- CamelFolderThread structure at the same time */
- g_mutex_lock (&message_list->priv->thread_tree_lock);
- camel_folder_thread_messages_apply (thread_tree, uids);
- g_mutex_unlock (&message_list->priv->thread_tree_lock);
- } else
- thread_tree = camel_folder_thread_messages_new (
- folder, uids, regen_data->thread_subject);
+ /* Always build a new thread_tree, to avoid race condition
+ when accessing it here and in the build_tree() call
+ from multiple threads. */
+ thread_tree = camel_folder_thread_messages_new (folder, uids, regen_data->thread_subject);
/* We will build the ETreeModel content from this
* CamelFolderThread during regen post-processing.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]