Bug 3793 - Segfaults when master passphrase dialog is launched in the middle of autocompletion
Summary: Segfaults when master passphrase dialog is launched in the middle of autocomp...
Status: RESOLVED FIXED
Alias: None
Product: Claws Mail (GTK 2)
Classification: Unclassified
Component: UI (show other bugs)
Version: 3.15.1
Hardware: PC Linux
: P3 normal
Assignee: users
URL:
Depends on:
Blocks:
 
Reported: 2017-03-28 20:26 UTC by Ricardo Mones
Modified: 2017-12-10 18:24 UTC (History)
0 users

See Also:


Attachments

Description Ricardo Mones 2017-03-28 20:26:54 UTC
How to reproduce:
• Have enough contacts in your AddressBook :)
• Open compose window
• Type one letter, e.g.: 'a'
• Press Tab key

Expected result:
• Drop down list opens and you can continue typing up to completion

Actual result:
• Drop down list opens and Claws Mail segfaults (message can only be seen
  under gdb, see note below):
,-----
| Program received signal SIGSEGV, Segmentation fault.
| 0x00007ffff6cfb7d4 in gdk_window_set_geometry_hints () from /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0
`-----

While 'enough contacts' may sound vague, in fact there's no need for so many contacts: an AddressBook's Book (XML file) with 309 contacts is enough for triggering this in my case and there's 399 total contacts in AB.

My suspect is that the results returned by matching are not cut at some sane number and it's trying to build a window too large with them, but this is just a wild guess.

Note: while trying to debug this in my computer the whole X became frozen, and have to kill Claws Mail or gdb from a text console to regain control. The latter makes impossible to get a backtrace, so ideas on how to get one are welcome.
Comment 1 Ricardo Mones 2017-04-02 03:33:27 UTC
After some investigation seems this is not caused by a big number of addresses on address book, but by the master passphrase dialog being launched in the middle of the address completion ([0] and [1] are added debug_print, not in current code):

ldapquery.c:694:===ldapqry_connect===
ldapserver.c:731:cert Success
ldapserver.c:737:tm Success
ldapserver.c:806:Got handle to LDAP host 192.168.1.5 on port 389
ldapserver.c:809:Setting version 3
passwordstore.c:180:Getting password '192.168.1.5' from block (0/LDAP)
passwordstore.c:189:[0] Grabbing pointer
passwordstore.c:198:[1] Decrypting password
Segmentation fault

The decrypting process calls password.c:master_passphrase(), which launches the dialog when the password is not in memory.

This somehow makes the program crash, probably because both windows (dialog and autocompletion) are assuming they're the only one running and both try to grab input and/or focus.
Comment 2 Ricardo Mones 2017-04-04 01:01:26 UTC
An alternative abort message also caused by this:

[xcb] Unknown request in queue while dequeuing
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
claws-mail: ../../src/xcb_io.c:179: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed.
Aborted

(Amazing! :)
Comment 3 users 2017-12-10 18:14:04 UTC
Changes related to this bug have been committed.
Please check latest Git and update the bug accordingly.
You can also get the patch from:
http://git.claws-mail.org/

++ ChangeLog	2017-12-10 18:14:03.093337675 +0100
http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=fcff54c23bcab3ddb3c0d3d7c0e700049427adc0
Merge: 446fd06 e0f4140
Author: Colin Leroy <colin@colino.net>
Date:   Sun Dec 10 18:14:02 2017 +0100

    Merge branch 'master' of file:///home/git/claws

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=e0f41407ce397eed880ba0360d9b5725f9176ed8
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Sun Dec 10 10:49:02 2017 +0100

    Fix bug 3931: segfault searching server with master password
    
    Request master passphrase earlier and inhibit search if no master
    passphrase is available.

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=48f72c22f91fbe0d6e872e89bd4dce9d39090e81
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Sun Dec 10 10:49:01 2017 +0100

    Fix bug 3793: segfault when autocompletion asks for master passphrase
    
    This is done by checking early if any ldap server is password-protected,
    and asking for master passphrase when compose window appears.  If user
    cancels the dialog (does not enter the passphrase), we temporarily
    disable the password-protected LDAP servers, just for that particular
    compose window. We reenable them in compose_destroy().

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=d954a01de48f90a726e79995f4daeed3e9fee11b
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Sun Dec 10 10:49:00 2017 +0100

    Add public call to get master password

Note You need to log in before you can comment on or make changes to this bug.