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 765515 - Crash and/or search results not highlighted, "database disk image is malformed" in debug log
Crash and/or search results not highlighted, "database disk image is malforme...
Status: RESOLVED FIXED
Product: geary
Classification: Other
Component: search
master
Other Linux
: Normal critical
: 0.11.0
Assigned To: Geary Maintainers
Geary Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-04-25 06:07 UTC by Michael Gratton
Modified: 2016-10-13 04:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Example error log (1.16 KB, text/plain)
2016-04-25 06:07 UTC, Michael Gratton
  Details
Workaround for the crash (1.58 KB, patch)
2016-05-02 08:17 UTC, Michael Gratton
none Details | Review

Description Michael Gratton 2016-04-25 06:07:53 UTC
Created attachment 326656 [details]
Example error log

Occasionally, search highlights missing from a search result, and "Error highlighting search results: ... - database disk image is malformed" is reported in the debug log.

Seems the issue might be the use of 'offsets()' in the Geary.ImapDB.Account::do_get_search_matches query occasionally flaking out:

> sqlite> SELECT docid, offsets(MessageSearchTable) FROM MessageSearchTable WHERE docid IN (757) AND MessageSearchTable MATCH 'fr*';
> Error: database disk image is malformed
> sqlite> SELECT docid FROM MessageSearchTable WHERE docid IN (757) AND MessageSearchTable MATCH 'fr*';
> 757

Here, docid 757 contains several strings that match "fr*", and also has some empty columns (attachment, cc, bcc), which looks like a SQLIte issue in earlier versions, i.e.: <http://sqlite.1065341.n5.nabble.com/regression-in-FTS3-offsets-function-in-3-6-23-td15216.html> and <http://www.sqlite.org/src/info/9861b74ab9>.

Since I am using SQLite 3.11.0 this may be a regression, although I can't reproduce the issue in the same way as in the nabble post above with this version, even when using unicodesn as the tokeniser.
Comment 1 Michael Gratton 2016-05-02 07:54:01 UTC
This is also causing segfaults:

  • #0 __GI_____strtol_l_internal
    at ../stdlib/strtol_l.c line 293
  • #1 __strtol
    at ../stdlib/strtol.c line 106
  • #2 geary_imap_db_account_do_get_search_matches
    at /usr/include/stdlib.h line 280
  • #3 geary_imap_db_account_do_get_search_matches
    at /home/mjg/Projects/GNOME/geary/src/engine/imap-db/imap-db-account.vala line 1912
  • #4 ___lambda123__geary_db_transaction_method
    at /home/mjg/Projects/GNOME/geary/src/engine/imap-db/imap-db-account.vala line 1170
  • #5 ___lambda123__geary_db_transaction_method
    at imap-db-account.c line 13970
  • #6 geary_db_connection_exec_transaction
    at /home/mjg/Projects/GNOME/geary/src/engine/db/db-connection.vala line 394
  • #7 geary_db_transaction_async_job_execute
    at /home/mjg/Projects/GNOME/geary/src/engine/db/db-transaction-async-job.vala line 39
  • #8 _geary_db_database_on_async_job_gfunc
    at /home/mjg/Projects/GNOME/geary/src/engine/db/db-database.vala line 283
  • #9 _geary_db_database_on_async_job_gfunc
    at /home/mjg/Projects/GNOME/geary/src/engine/db/db-database.vala line 80
  • #10 g_thread_pool_thread_proxy
    at /build/glib2.0-t9oPgV/glib2.0-2.48.0/./glib/gthreadpool.c line 307
  • #11 g_thread_proxy
    at /build/glib2.0-t9oPgV/glib2.0-2.48.0/./glib/gthread.c line 780
  • #12 start_thread
    at pthread_create.c line 333
  • #13 clone
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S line 109

Here, in ::do_get_search_matches, the int64 returned for the 1st column (the docid") is non-null, the string returned for the 2nd column (offsets) is null, hence (?) the value of offset_string[0] is null and int.parse() segfaults.

Executing the same query from the sqlite command line results in a number of results being returned before the "database disk image is malformed" error eventually crops up. So presumably we get an error returned for the row when this occurs for the first result, but none when it occurs for the second or subsequent result?
Comment 2 Michael Gratton 2016-05-02 08:17:14 UTC
Created attachment 327133 [details] [review]
Workaround for the crash
Comment 3 Michael Gratton 2016-05-04 02:49:53 UTC
Adam, this workaround seems to work fine - can you also commit this, but leave the bug open for now.
Comment 4 Adam Dingle 2016-05-05 11:45:53 UTC
OK - I pushed the workaround to master.
Comment 5 Michael Gratton 2016-10-13 04:02:48 UTC
Closing this, since the workaround has been committed it looks like the root cause has been identified over in Bug 772522.