After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 757789 - [IMAPx] Incorrect unref of a message info on message copy
[IMAPx] Incorrect unref of a message info on message copy
Status: RESOLVED FIXED
Product: evolution
Classification: Applications
Component: general
3.18.x (obsolete)
Other Linux
: Normal critical
: ---
Assigned To: Evolution Shell Maintainers Team
Evolution QA team
: 758836 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2015-11-08 20:15 UTC by Giuseppe Sacco
Modified: 2016-02-17 16:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
valgrind log (8.12 KB, application/octet-stream)
2015-11-10 21:05 UTC, Giuseppe Sacco
Details

Description Giuseppe Sacco 2015-11-08 20:15:46 UTC
Hello,
I just selected an IMAP folder and deleted it. Evolution warned me about all included messages that would be deleted, and I accepted it. Then evolution crashed as shown in the following backtrace. I then restarted evolution and found the folder was really deleted and all messages were in the Trash. So, it might be crashed after the folder was successfully deleted.

This is Debian testing with evolution 3.18.1.

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt full
  • #0 ??
  • #1 is_node_selectable
    at message-list.c line 3912
  • #2 find_next_selectable
    at message-list.c line 3960
  • #3 message_list_regen_done_cb
    at message-list.c line 5825
  • #4 g_simple_async_result_complete
    from /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
  • #5 ??
    from /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
  • #6 g_main_context_dispatch
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #7 ??
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #8 g_main_loop_run
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #9 gtk_main
    from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
  • #10 main
    at main.c line 654

Comment 1 Giuseppe Sacco 2015-11-08 20:29:39 UTC
A second try, on a different folder, produced a different backtrace:

Program received signal SIGSEGV, Segmentation fault.

Thread 140734736889600 (LWP 11881)

  • #0 g_slice_alloc
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #1 g_slice_alloc0
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #2 g_type_create_instance
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #3 ??
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #4 g_object_new_valist
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #5 g_object_new
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #6 camel_imapx_search_new
    at camel-imapx-search.c line 634
  • #7 camel_imapx_folder_new
    at camel-imapx-folder.c line 1118
  • #8 get_folder_offline
    at camel-imapx-store.c line 928
  • #9 imapx_store_get_folder_sync
    at camel-imapx-store.c line 1727
  • #10 camel_store_get_folder_sync
  • #11 store_get_folder_thread
    at camel-store.c line 1391
  • #12 ??
    from /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
  • #13 ??
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #14 ??
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #15 start_thread
    at pthread_create.c line 309
  • #16 clone
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S line 111
(gdb)
Comment 2 Giuseppe Sacco 2015-11-09 08:59:19 UTC
I did some more testing and found that the same problem happens even when not deleting folders. This is a backtrace of a crash after moving a message from inbox to a different folder:

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt full
  • #0 ??
  • #1 is_node_selectable
    at message-list.c line 3912
  • #2 find_next_selectable
    at message-list.c line 3960
  • #3 message_list_regen_done_cb
    at message-list.c line 5825
  • #4 g_simple_async_result_complete
    from /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
  • #5 ??
    from /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
  • #6 g_main_context_dispatch
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #7 ??
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #8 g_main_loop_run
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #9 gtk_main
    from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
  • #10 main
    at main.c line 654

Comment 3 Milan Crha 2015-11-09 18:38:12 UTC
Thanks for a bug report. I tried to reproduce this, but no luck. It seems you are able to reproduce this consistently, thus I'd like to ask you for any details you can share to reproduce the crash.

You are right that this happened only after the message/folder had been deleted, as this crashed after the message list had been rebuilt and the previously selected message was about to be selected.

It can be anything from the used view (threaded/not threaded, wide/classic view, show/hidden deleted messages, certain sort ordering, and so on) and the selected message you tried to move (to/bottom of the message list, leaf/middle/root node of some thread, ...) and how you moved it (drag&drop, through context menu, keyboard shortcut,...). Any detail matters.

Thanks in advance.
Comment 4 Giuseppe Sacco 2015-11-09 20:19:10 UTC
I use threaded view, hiding deleted messages, sorted by date (top older, bottom newer). I moved a message (a thread composed by only that message, so it was root and leaf of the thread) dragging it with mouse over the destination folder name.

I don't know what the wide/classic view are. Could you explain that? Is there anything mode I can do? Do you have special arguments I should use when running evolution? Or, do I need to install any package?

Thanks,
Giuseppe
Comment 5 Milan Crha 2015-11-10 06:20:05 UTC
(In reply to Giuseppe Sacco from comment #4)
> I use threaded view, hiding deleted messages, sorted by date (top older,
> bottom newer). I moved a message (a thread composed by only that message, so
> it was root and leaf of the thread) dragging it with mouse over the
> destination folder name.

Hmm, I tried the same here.

> I don't know what the wide/classic view are. Could you explain that?

You can change it in View->Preview menu. I see I used wrong terms, they are called Classic and Vertical view.

> Is there anything mode I can do? Do you have special arguments I should use
> when running evolution? Or, do I need to install any package?

I do not have anything for these. You already seem to have installed debuginfo package for the evolution (your backtrace gives exact line numbers). Maybe if you try to reproduce it under valgrind, but that is quite slow. Considering that we do exactly the same steps and I'm not able to reproduce this, I'm wondering how much this is related to "proper timing", which the run under valgrind can "break", due to its slowness. If you want to give it a try, the command would look like:
   $ G_SLICE=always-malloc valgrind evolution &>log.txt
Comment 6 Giuseppe Sacco 2015-11-10 20:30:10 UTC
Hello,
I just got a new SISEGV. This time I selected a few threads and applied all rules for moving them in specific folders. Evolution got the signal and I still see all these messages selected in my INBOX.

This stack trace is longer than the previous one, so I don't know if it can be helpful. Could you check if the stack trace is the same? Tomorrow I'll give it a try at valgrind.

Program received signal SIGSEGV, Segmentation fault.

Thread 140734736889600 (LWP 6473)

  • #0 g_slice_alloc
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #1 g_slice_alloc0
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #2 camel_message_info_new
    at camel-folder-summary.c line 4468
  • #3 message_info_from_db
    at camel-folder-summary.c line 562
  • #4 imapx_summary_message_info_from_db
    at camel-imapx-summary.c line 121
  • #5 camel_read_mir_callback
    at camel-folder-summary.c line 2590
  • #6 sqlite3_exec
    at sqlite3.c line 103979
  • #7 cdb_sql_exec
    at camel-db.c line 510
  • #8 camel_db_select
    at camel-db.c line 1223
  • #9 camel_db_read_message_info_record_with_uid
    at camel-db.c line 2114
  • #10 message_info_from_uid
    at camel-folder-summary.c line 1882
  • #11 imapx_server_process_fetch_changes_infos
    at camel-imapx-server.c line 4664
  • #12 imapx_server_fetch_changes
    at camel-imapx-server.c line 4737
  • #13 camel_imapx_server_refresh_info_sync
    at camel-imapx-server.c line 4914
  • #14 imapx_conn_manager_refresh_info_run_sync
    at camel-imapx-conn-manager.c line 1187
  • #15 camel_imapx_job_run_sync
    at camel-imapx-job.c line 473
  • #16 camel_imapx_conn_manager_run_job_sync
    at camel-imapx-conn-manager.c line 986
  • #17 camel_imapx_conn_manager_refresh_info_sync
    at camel-imapx-conn-manager.c line 1214
  • #18 imapx_refresh_info_sync
    at camel-imapx-folder.c line 745
  • #19 camel_folder_refresh_info_sync
    at camel-folder.c line 3501
  • #20 close_folder
    at camel-filter-driver.c line 1159
  • #21 g_hash_table_foreach
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #22 close_folders
    at camel-filter-driver.c line 1181
  • #23 filter_driver_finalize
    at camel-filter-driver.c line 220
  • #24 g_object_unref
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #25 em_filter_folder_element_exec
    at mail-ops.c line 141
  • #26 mail_msg_proxy
    at mail-mt.c line 383
  • #27 ??
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #28 ??
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #29 start_thread
    at pthread_create.c line 309
  • #30 clone
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S line 111

Comment 7 Giuseppe Sacco 2015-11-10 21:05:20 UTC
Created attachment 315214 [details]
valgrind log

Valgrind log of Evolution crashed after deleting an imap folder.

Bye,
Giuseppe
Comment 8 Milan Crha 2015-11-11 11:33:36 UTC
(In reply to Giuseppe Sacco from comment #6)
> This stack trace is longer than the previous one, so I don't know if it can
> be helpful. Could you check if the stack trace is the same?

It's a different place. Looks like a memory corruption, some code probably wrote somewhere where it should not or some structure was freed before it should be freed. The valgrind caught both issues, and looking into it it seems to me that they are related.

Would you mind to install debuginfo packages for the evolution-data-server and evolution, please? I do not need debuginfo for their dependencies, the debuginfo only for them two would be great. That will show also line numbers, eventually will make the backtrace more detailed. I can see some things even without that, based on the shown function numbers, thus it's not a problem if you'll not have a time or resources to do it.

What I understand from the valgrind log is that the add_present_rec() in 
camel-folder-thread.c freed the CamelMessageInfo structure by unreferencing its last reference. It looks like the dereference is correct, at least after a brief code reading, thus it can be that some calls related to the message move and/or the folder deletion did the message info unref incorrectly and it caused the crash. I'll investigate further and will let you know as soon as I'll have something.

Thanks for your help with this.
Comment 9 Giuseppe Sacco 2015-11-11 11:58:35 UTC
I cannot really understand what you mean: the packages you request are already installed. What am I missing?

giuseppe@uefi:~$ LC_ALL=C dpkg -l \*evolution\*| grep -v ^un
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                           Version            Architecture Description
+++-==============================-==================-============-==========================================================
ii  evolution                      3.18.1-1           amd64        groupware suite with mail client and organizer
ii  evolution-common               3.18.1-1           all          architecture independent files for Evolution
ii  evolution-data-server          3.18.1-1           amd64        evolution database backend server
ii  evolution-data-server-common   3.18.1-1           all          architecture independent files for Evolution Data Server
ii  evolution-data-server-dbg      3.18.1-1           amd64        evolution database backend server with debugging symbols
ii  evolution-dbg                  3.18.1-1           amd64        debugging symbols for Evolution
ii  evolution-plugins              3.18.1-1           amd64        standard plugins for Evolution
ii  libevolution                   3.18.1-1           amd64        evolution libraries
ii  libreoffice-evolution          1:5.0.3~rc2-1+b1   amd64        office productivity suite -- Evolution addressbook support
ii  openoffice.org-evolution       1:3.4.0~ooo340m1-7 all          office productivity suite -- Evolution addressbook support
Comment 10 Milan Crha 2015-11-11 13:08:05 UTC
Weird, neither gdb nor valgrind is using those -dbg packages, while you have both of them of the right version, thus it should just work. The backtrace should show also source files and line numbers in the backtraces, if everything works fine. Never mind then, the info in them is also useful, only not that detailed.
Comment 11 Milan Crha 2015-11-11 16:21:12 UTC
I've got it. The problem is that the routine which copies (moves) messages within the server unreferenced the message info twice, which caused a use-after-free in later calls, like the one in comment #0.

I wasn't able to reproduce this, then I realized that the COPYUID status is not passed back properly, thus I fixed that, but even that wasn't enough. Finally, I figured from the valgrind log that you've setup a real Trash folder for your IMAP account. That made the difference and I also got a crash on folder deletion. The thing is that with the real Trash folder the routine to copy messages into that Trash folder is called, thus it garbled the memory and caused the crash.

Thanks a lot for your help with this.

Created commit 97c1584 in eds master (3.19.2+)
Created commit 47488ae in eds gnome-3-18 (3.18.3+)
Comment 12 Giuseppe Sacco 2015-11-11 20:06:12 UTC
I just applied this fix to debian package and rebuilt it. I cannot reproduce the problem any more.

Thank you very much.
Comment 13 Milan Crha 2015-11-12 13:42:38 UTC
Nice, thanks a lot for the confirmation.
Comment 14 Milan Crha 2015-11-16 08:29:50 UTC
Downstream bug report about the same:
https://bugzilla.redhat.com/show_bug.cgi?id=1281331
Comment 15 Milan Crha 2015-11-30 12:55:33 UTC
*** Bug 758836 has been marked as a duplicate of this bug. ***
Comment 16 Milan Crha 2016-01-19 18:47:53 UTC
*** Bug 759101 has been marked as a duplicate of this bug. ***
Comment 17 Milan Crha 2016-02-17 16:44:19 UTC
I reopened bug #759101 for one case where a similar backtrace could be shown, but the circumstances of the crash were very different.