Bug 321272 - Crash when sending email - error during ssl greeting
Summary: Crash when sending email - error during ssl greeting
Status: RESOLVED FIXED
Alias: None
Product: trojita
Classification: Unclassified
Component: SMTP (show other bugs)
Version: git
Platform: openSUSE RPMs Linux
: NOR critical (vote)
Target Milestone: ---
Assignee: Trojita default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-17 13:40 UTC by Nicolás Sirolli
Modified: 2013-06-18 17:51 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolás Sirolli 2013-06-17 13:40:23 UTC
I have Trojita configured to send email using Secure SMTP. When I try to send an email, after pressing the Send button I get two error windows, saying:

- The remote computer has closed the connection.
- Error during the SSL greeting: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol.

After clicking Accept in one of these windows, Trojita crashes and closes.

Reproducible: Always

Steps to Reproduce:
1. Send an email.
2.
3.
Actual Results:  
Trojita crashes, and the email is not sent.

Expected Results:  
Send the email

Here is the log:

10:24:42.6610  Submission STATE_INIT
10:24:42.6670  Submission STATE_BUILDING_MESSAGE
10:24:42.6960  Submission STATE_SAVING
10:24:42.6991  [task] Imap::Mailbox::GetAnyConnectionTask Activado
10:24:42.7001  [task] Imap::Mailbox::GetAnyConnectionTask Completed
10:24:42.7001  [task] Imap::Mailbox::AppendTask Activado
10:24:42.7031  >>>  y25 APPEND "Mail/Enviados" ($SubmitPending \Seen) "17-Jun-2013 10:24:42 -0300" {737+}␍␊From: =?iso-8859-1?Q?Nicol=E1s_Sirolli?= <nsirolli@dm.uba.ar>␍␊To: =?iso-8859-1?Q?Nicol=E1s_Sirolli?= <nsirolli@dm.uba.ar>␍␊Subject: Re: Prueba...␍␊Date: Mon, 17 Jun 2013 10:24:42 -0300␍␊User-Agent: trojita/0.3.93-git; Qt/4.8.4; X11; Linux; openSUSE 12.3 (x86_64)␍␊MIME-Version: 1.0␍␊Message-ID: <af2fb220-e1b1-4ba6-8ef9-68bf14cb84ea@dm.uba.ar>␍␊In-Reply-To: <5614c7eb-960a-493f-8255-32ce6da176cf@dm.uba.ar>␍␊References: <5614c7eb-960a-493f-8255-32ce6da176cf@dm.uba.ar>␍␊Organization: Departamento de =?iso-8859-1?Q?Matem=E1tica_-_FCEyN,_UBA?=␍␊Content-Type: text/plain; charset=utf-8; format=flowed␍␊Content-Transfer-Encoding: quoted-printable␍␊␍␊El lunes 17 de junio de 2013 10h'22:34 ART, Nicol=C3=A1s Sirolli escrib=␍␊i=C3=B3:=0A>=0A
10:24:42.7551  <<<  * 3178 EXISTS
10:24:42.7551  <<<  * 2 RECENT
10:24:42.7551  <<<  y25 OK [APPENDUID 1185121108 3349] Unknown flag: $SubmitPending
10:24:42.7561  [task] Imap::Mailbox::AppendTask Completed
10:24:42.7560  Submission STATE_SUBMITTING
10:24:42.7571  >>>  y26 UID FETCH 3349:* (FLAGS)
10:24:42.7911  <<<  * 3178 FETCH (UID 3349 FLAGS (\Recent \Seen))
10:24:42.7911  <<<  y26 OK UID FETCH completed
10:24:42.8041  [task] Imap::Mailbox::FetchMsgMetadataTask Mail/Enviados: UIDs 3349 Activado
10:24:42.8111  >>>  y27 UID FETCH 3349 (ENVELOPE INTERNALDATE BODYSTRUCTURE RFC822.SIZE BODY.PEEK[HEADER.FIELDS (References List-Post)])
10:24:42.8381  <<<  * 3178 FETCH (UID 3349 ENVELOPE ("Mon, 17 Jun 2013 10:24:42 -0300" "Re: Prueba..." (("=?iso-8859-1?Q?Nicol=E1s_Sirolli?=" NIL "nsirolli" "dm.uba.ar")) (("=?iso-8859-1?Q?Nicol=E1s_Sirolli?=" NIL "nsirolli" "dm.uba.ar")) (("=?iso-8859-1?Q?Nicol=E1s_Sirolli?=" NIL "nsirolli" "dm.uba.ar")) (("=?iso-8859-1?Q?Nicol=E1s_Sirolli?=" NIL "nsirolli" "dm.uba.ar")) NIL NIL "<5614c7eb-960a-493f-8255-32ce6da176cf@dm.uba.ar>" "<af2fb220-e1b1-4ba6-8ef9-68bf14cb84ea@dm.uba.ar>") INTERNALDATE "17-Jun-2013 10:24:42 -0300" BODYSTRUCTURE ("TEXT" "PLAIN" ("CHARSET" "utf-8" "FORMAT" "flowed") NIL NIL "QUOTED-PRINTABLE" 89 1 NIL NIL NIL NIL) RFC822.SIZE 737 BODY[HEADER.FIELDS (REFERENCES LIST-POST)] {64}␍␊References: <5614c7eb-960a-493f-8255-32ce6da176cf@dm.uba.ar>␍␊␍␊)
10:24:42.8391  <<<  y27 OK UID FETCH completed
10:24:42.8391  [task] Imap::Mailbox::FetchMsgMetadataTask Mail/Enviados: UIDs 3349 Completed
10:24:45.7940  Submission gotError: Error durante el saludo SSL: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
10:24:45.7940  Submission STATE_FAILED
10:24:45.8110  Submission gotError: El equipo remoto ha cerrado la conexión
10:24:45.8120  Submission STATE_FAILED
10:24:48.8401  >>>  y28 IDLE
10:24:48.9071  <<<  + Waiting for DONE
10:25:20.4590  Submission STATE_UPDATING_FLAGS
10:25:20.4651  >>>  DONE
10:25:20.4661  [task] Imap::Mailbox::UpdateFlagsTask Activado
10:25:20.4721  >>>  y29 UID STORE 3348 +FLAGS (\Answered)
10:25:20.4851  <<<  y28 OK IDLE completed
10:25:20.5001  <<<  * 3177 FETCH (FLAGS (\Recent \Seen \Answered) UID 3348)
10:25:20.5011  <<<  y29 OK UID STORE completed
10:25:20.5011  [task] Imap::Mailbox::UpdateFlagsTask Completed
10:25:20.5010  Submission STATE_SENT
Comment 1 Jan Kundrát 2013-06-17 14:41:01 UTC
Thanks, Trojita should definitely not crash :). Could you please provide the following information and reopen this bugreport?

- The SMTP settings: hostname, port, connection method, state of the "perform STARTTLS"
- Could you also get a proper backtrace? Simply installing the trojita-nightly-debuginfo and running the application from inside `gdb` shall do the trick (run `gdb --ex run trojita`, make it crash, then enter `backtrace` at the gdb prompt and report the result).

When you have attached the requested data, please do not forget to reopen this bugreport.
Comment 2 Nicolás Sirolli 2013-06-17 15:04:51 UTC
My SMTP settings are the following:

Hostname: smtp.dm.uba.ar
Port: 587
Connection method: Secure SMTP
Perform SSTARTTLS: Yes (this option is grey, and can not be changed)
Authenticate: Yes

Here is the backtrace:

(gdb) backtrace
#0  0x00007ffff362e3d5 in raise () from /lib64/libc.so.6                                                                                                                                        
#1  0x00007ffff362f858 in abort () from /lib64/libc.so.6                                                                                                                                        
#2  0x00007ffff366e07b in __libc_message () from /lib64/libc.so.6                                                                                                                               
#3  0x00007ffff3673bf6 in malloc_printerr () from /lib64/libc.so.6                                                                                                                              
#4  0x00007ffff3674973 in _int_free () from /lib64/libc.so.6                                                                                                                                    
#5  0x00007ffff456c4c2 in QObjectPrivate::deleteChildren() () from /usr/lib64/libQtCore.so.4                                                                                                    
#6  0x00007ffff4e1c3cc in QWidget::~QWidget() () from /usr/lib64/libQtGui.so.4                                                                                                                  
#7  0x0000000000482368 in ?? ()                                                                                                                                                                 
#8  0x00000000004823ee in ?? ()                                                                                                                                                                 
#9  0x00007ffff456e7a8 in QObject::event(QEvent*) () from /usr/lib64/libQtCore.so.4                                                                                                             
#10 0x00007ffff4e2188a in QWidget::event(QEvent*) () from /usr/lib64/libQtGui.so.4                                                                                                              
#11 0x00007ffff4dd286c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib64/libQtGui.so.4                                                                                
#12 0x00007ffff4dd6ceb in QApplication::notify(QObject*, QEvent*) () from /usr/lib64/libQtGui.so.4                                                                                              
#13 0x00007ffff4559d8e in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib64/libQtCore.so.4                                                                                 
#14 0x00007ffff455d6f1 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()                                                                                             
   from /usr/lib64/libQtCore.so.4                                                                                                                                                               
#15 0x00007ffff4588133 in ?? () from /usr/lib64/libQtCore.so.4                                                                                                                                  
#16 0x00007ffff10ba7d5 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0                                                                                                           
#17 0x00007ffff10bab08 in ?? () from /usr/lib64/libglib-2.0.so.0
#18 0x00007ffff10babc4 in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#19 0x00007ffff45882c6 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /usr/lib64/libQtCore.so.4
#20 0x00007ffff4e72c1e in ?? () from /usr/lib64/libQtGui.so.4
#21 0x00007ffff4558adf in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/libQtCore.so.4
#22 0x00007ffff4558d68 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/libQtCore.so.4
#23 0x00007ffff52869c8 in QDialog::exec() () from /usr/lib64/libQtGui.so.4
#24 0x00007ffff52a7242 in ?? () from /usr/lib64/libQtGui.so.4
#25 0x00007ffff52a730f in QMessageBox::critical(QWidget*, QString const&, QString const&, QFlags<QMessageBox::StandardButton>,---Type <return> to continue, or q <return> to quit---
Comment 3 Thomas Lübking 2013-06-17 15:09:22 UTC
#7  0x0000000000482368 in ?? ()                                                                                                                                                                 
#8  0x00000000004823ee in ?? ()                    

lacks interesting section, but crashes for loosing a qobject during a nested eventloop (and usually try deleting it afterwards) -> strategy is QWeakPointer around every "::exec()".
Comment 4 Jan Kundrát 2013-06-17 16:00:06 UTC
Unfortunately, I still cannot reproduce this. Nicolas, please make sure that you have reinstalled both the trojita-nightly and trojita-nightly-debuginfo packages, and try once again. (If you use the non-nightly variant, it's "trojita" and "trojita-debuginfo".) The failure *could* be in the ComposeWidget::gotError, but I'd like to understand how this gets triggered in the first place.

The IMAP log also suggests that you're trying to reply to an existing mail. Is that important? Does it crash even when writing a mail "from scratch"?

Anyway, there's one more error in the log, the logic wrapping the mail submission proceeds further even though the actual submission failed -- the code should have never proceed to the STATE_UPDATING_FLAGS state. This is due to another bug in the QwwSmtpClient, see https://git.reviewboard.kde.org/r/111073/ for a fix. After that is merged, I'd be interested to know whether it happens to fix the problem for Nicolas.
Comment 5 Nicolás Sirolli 2013-06-17 16:20:26 UTC
I'm sorry, I was using trojita-nightly and the non-nightly debug package; maybe that was the problem. Here I go again, with both nightly versions:

(gdb) backtrace
#0  0x00007ffff3677654 in free () from /lib64/libc.so.6
#1  0x00007ffff456c4c2 in QObjectPrivate::deleteChildren() () from /usr/lib64/libQtCore.so.4
#2  0x00007ffff4e1c3cc in QWidget::~QWidget() () from /usr/lib64/libQtGui.so.4
#3  0x0000000000482368 in Gui::ComposeWidget::~ComposeWidget (this=0xefc6f0, __in_chrg=<optimized out>)
    at ComposeWidget.cpp:141
#4  0x00000000004823ee in Gui::ComposeWidget::~ComposeWidget (this=0xefc6f0, __in_chrg=<optimized out>)
    at ComposeWidget.cpp:144
#5  0x00007ffff456e7a8 in QObject::event(QEvent*) () from /usr/lib64/libQtCore.so.4
#6  0x00007ffff4e2188a in QWidget::event(QEvent*) () from /usr/lib64/libQtGui.so.4
#7  0x00007ffff4dd286c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib64/libQtGui.so.4
#8  0x00007ffff4dd6ceb in QApplication::notify(QObject*, QEvent*) () from /usr/lib64/libQtGui.so.4
#9  0x00007ffff4559d8e in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib64/libQtCore.so.4
#10 0x00007ffff455d6f1 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()
   from /usr/lib64/libQtCore.so.4
#11 0x00007ffff4588133 in ?? () from /usr/lib64/libQtCore.so.4
#12 0x00007ffff10ba7d5 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
#13 0x00007ffff10bab08 in ?? () from /usr/lib64/libglib-2.0.so.0
#14 0x00007ffff10babc4 in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#15 0x00007ffff45882c6 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /usr/lib64/libQtCore.so.4
#16 0x00007ffff4e72c1e in ?? () from /usr/lib64/libQtGui.so.4
#17 0x00007ffff4558adf in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/libQtCore.so.4
#18 0x00007ffff4558d68 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/libQtCore.so.4
#19 0x00007ffff52869c8 in QDialog::exec() () from /usr/lib64/libQtGui.so.4
#20 0x00007ffff52a7242 in ?? () from /usr/lib64/libQtGui.so.4
#21 0x00007ffff52a730f in QMessageBox::critical(QWidget*, QString const&, QString const&, QFlags<QMessageBox::StandardButton>, QMessageBox::StandardButton) () from /usr/lib64/libQtGui.so.4
#22 0x0000000000484e1e in Gui::ComposeWidget::gotError (this=0xefc6f0, error=...) at ComposeWidget.cpp:515

I was replying to an existing mail, but that is not important. The log above is from a crash obtained by writing a mail from scratch.
Comment 6 Thomas Lübking 2013-06-17 21:42:57 UTC
@ Nicolas:
a) Does the composer widget close? (running in gdb you should be able to see that)
b) If so: when? Before or after clicking the dialog?
c) Can you compile a patch?
Comment 7 Jan Kundrát 2013-06-18 10:23:32 UTC
I can reproduce this problem now. A few simple steps:

- Connect to SMTP using SSL to a port of the plaintext service (e.g. "secure SMTP" to port 25)
- Set up the SMTP server so that it has a low timeout
- Try sending mail, an error message about SSL pops up immediately. Do *not* click on it.
- Wait for another error message when the timeout finally kicks in. A second message box appears, and this is the backtrace:

#0  0x00007f90d7bbe533 in __GI___poll (fds=<optimized out>, nfds=<optimized out>, timeout=<optimized out>) at ../sysdeps/unix/sysv/linux/poll.c:87
#1  0x00007f90d8921916 in g_main_context_poll (n_fds=6, fds=0x2944710, timeout=49, context=0x244eb00, priority=<optimized out>) at gmain.c:3440
#2  g_main_context_iterate (context=0x244eb00, block=1, dispatch=1, self=<optimized out>) at gmain.c:3141
#3  0x00007f90d8921a6c in g_main_context_iteration (context=0x244eb00, may_block=1) at gmain.c:3207
#4  0x00007f90d91f389f in QEventDispatcherGlib::processEvents (this=0x2448990, flags=...) at kernel/qeventdispatcher_glib.cpp:424
#5  0x00007f90d9b3b156 in QGuiEventDispatcherGlib::processEvents (this=<optimized out>, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
#6  0x00007f90d91bbc92 in QEventLoop::processEvents (this=<optimized out>, flags=...) at kernel/qeventloop.cpp:149
#7  0x00007f90d91bc007 in QEventLoop::exec (this=0x7fff837f67f0, flags=...) at kernel/qeventloop.cpp:204
#8  0x00007f90d9fca66e in QDialog::exec (this=0x7fff837f6890) at dialogs/qdialog.cpp:554
#9  0x00007f90d9ff0698 in showNewMessageBox (parent=<optimized out>, icon=<optimized out>, title=..., text=..., buttons=..., defaultButton=QMessageBox::NoButton) at dialogs/qmessagebox.cpp:1538
#10 0x00007f90d9ff078f in QMessageBox::critical (parent=<optimized out>, title=..., text=..., buttons=..., defaultButton=<optimized out>) at dialogs/qmessagebox.cpp:1670
#11 0x000000000049cf56 in Gui::ComposeWidget::gotError (this=0x350c320, error=...) at ../../../../trojita/src/Gui/ComposeWidget.cpp:515
#12 0x00000000004cf570 in Gui::ComposeWidget::qt_static_metacall (_o=0x350c320, _c=QMetaObject::InvokeMetaMethod, _id=5, _a=0x7fff837f6b80) at moc_ComposeWidget.cpp:84
#13 0x00007f90d91d4ec1 in QMetaObject::activate (sender=0x2d85810, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7fff837f6b80) at kernel/qobject.cpp:3539
#14 0x0000000000618d0f in Composer::Submission::failed (this=0x2d85810, _t1=...) at moc_Submission.cpp:177
#15 0x0000000000615b96 in Composer::Submission::gotError (this=0x2d85810, error=...) at ../../../../trojita/src/Composer/Submission.cpp:289
#16 0x0000000000618a41 in Composer::Submission::qt_static_metacall (_o=0x2d85810, _c=QMetaObject::InvokeMetaMethod, _id=6, _a=0x7fff837f6dc0) at moc_Submission.cpp:88
#17 0x00007f90d91d4ec1 in QMetaObject::activate (sender=0x3c1ede0, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7fff837f6dc0) at kernel/qobject.cpp:3539
#18 0x00000000005e7a1f in MSA::AbstractMSA::error (this=0x3c1ede0, _t1=...) at moc_AbstractMSA.cpp:133
#19 0x00000000005e6087 in MSA::SMTP::handleError (this=0x3c1ede0, err=QAbstractSocket::RemoteHostClosedError, msg=...) at ../../../../trojita/src/MSA/SMTP.cpp:63
#20 0x00000000005e7d57 in MSA::SMTP::qt_static_metacall (_o=0x3c1ede0, _c=QMetaObject::InvokeMetaMethod, _id=2, _a=0x7fff837f6fa0) at moc_SMTP.cpp:54
#21 0x00007f90d91d4ec1 in QMetaObject::activate (sender=0x30c6e90, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7fff837f6fa0) at kernel/qobject.cpp:3539
#22 0x00000000005ee1cf in QwwSmtpClient::socketError (this=0x30c6e90, _t1=QAbstractSocket::RemoteHostClosedError, _t2=...) at ./moc_qwwsmtpclient.cpp:251
#23 0x00000000005ee128 in QwwSmtpClientPrivate::onError (this=0x4044d90, e=QAbstractSocket::RemoteHostClosedError) at ../../../../trojita/src/qwwsmtpclient/qwwsmtpclient.cpp:141
#24 0x00000000005f45f7 in QwwSmtpClient::qt_static_metacall (_o=0x30c6e90, _c=QMetaObject::InvokeMetaMethod, _id=16, _a=0x7fff837f7200) at ./moc_qwwsmtpclient.cpp:134
#25 0x00007f90d91d4ec1 in QMetaObject::activate (sender=0x3d71020, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7fff837f7200) at kernel/qobject.cpp:3539
#26 0x00007f90d9618cc1 in QAbstractSocket::error (this=<optimized out>, _t1=QAbstractSocket::RemoteHostClosedError) at .moc/release-shared/moc_qabstractsocket.cpp:247
#27 0x00007f90d963b7ce in QSslSocketPrivate::_q_errorSlot (this=0x3902510, error=QAbstractSocket::RemoteHostClosedError) at ssl/qsslsocket.cpp:2186
#28 0x00007f90d9641af7 in qt_static_metacall (_a=<optimized out>, _id=<optimized out>, _o=<optimized out>, _c=<optimized out>) at .moc/release-shared/moc_qsslsocket.cpp:97
#29 QSslSocket::qt_static_metacall (_o=<optimized out>, _c=<optimized out>, _id=<optimized out>, _a=<optimized out>) at .moc/release-shared/moc_qsslsocket.cpp:77
#30 0x00007f90d91d4ec1 in QMetaObject::activate (sender=0x30c7040, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7fff837f73d0) at kernel/qobject.cpp:3539
#31 0x00007f90d9618cc1 in QAbstractSocket::error (this=<optimized out>, _t1=QAbstractSocket::RemoteHostClosedError) at .moc/release-shared/moc_qabstractsocket.cpp:247
#32 0x00007f90d961b101 in QAbstractSocketPrivate::readFromSocket (this=0x34e5a50) at socket/qabstractsocket.cpp:1172
#33 0x00007f90d961b434 in QAbstractSocketPrivate::canReadNotification (this=0x34e5a50) at socket/qabstractsocket.cpp:628
#34 0x00007f90d9624931 in event (this=<optimized out>, e=<optimized out>) at socket/qnativesocketengine.cpp:1151
#35 QReadNotifier::event (this=<optimized out>, e=<optimized out>) at socket/qnativesocketengine.cpp:1148
#36 0x00007f90d9a7b794 in QApplicationPrivate::notify_helper (this=0x244c190, receiver=0x353cff0, e=0x7fff837f79f0) at kernel/qapplication.cpp:4562
#37 0x00007f90d9a8085d in QApplication::notify (this=0x7fff837fa810, receiver=0x353cff0, e=0x7fff837f79f0) at kernel/qapplication.cpp:3944
#38 0x00007f90d91bd70c in QCoreApplication::notifyInternal (this=0x7fff837fa810, receiver=0x353cff0, event=0x7fff837f79f0) at kernel/qcoreapplication.cpp:946
#39 0x00007f90d91f2dc8 in sendEvent (event=0x7fff837f79f0, receiver=<optimized out>) at kernel/qcoreapplication.h:231
#40 socketNotifierSourceDispatch (source=0x244fc80) at kernel/qeventdispatcher_glib.cpp:110
#41 0x00007f90d8921603 in g_main_dispatch (context=0x244eb00) at gmain.c:2539
#42 g_main_context_dispatch (context=0x244eb00) at gmain.c:3075
#43 0x00007f90d8921980 in g_main_context_iterate (context=0x244eb00, block=1, dispatch=1, self=<optimized out>) at gmain.c:3146
#44 0x00007f90d8921a6c in g_main_context_iteration (context=0x244eb00, may_block=1) at gmain.c:3207
#45 0x00007f90d91f391e in QEventDispatcherGlib::processEvents (this=0x2448990, flags=...) at kernel/qeventdispatcher_glib.cpp:426
#46 0x00007f90d9b3b156 in QGuiEventDispatcherGlib::processEvents (this=<optimized out>, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
#47 0x00007f90d91bbc92 in QEventLoop::processEvents (this=<optimized out>, flags=...) at kernel/qeventloop.cpp:149
#48 0x00007f90d91bc007 in QEventLoop::exec (this=0x7fff837f7c50, flags=...) at kernel/qeventloop.cpp:204
#49 0x00007f90d9fca66e in QDialog::exec (this=0x7fff837f7cf0) at dialogs/qdialog.cpp:554
#50 0x00007f90d9ff0698 in showNewMessageBox (parent=<optimized out>, icon=<optimized out>, title=..., text=..., buttons=..., defaultButton=QMessageBox::NoButton) at dialogs/qmessagebox.cpp:1538
#51 0x00007f90d9ff078f in QMessageBox::critical (parent=<optimized out>, title=..., text=..., buttons=..., defaultButton=<optimized out>) at dialogs/qmessagebox.cpp:1670
#52 0x000000000049cf56 in Gui::ComposeWidget::gotError (this=0x350c320, error=...) at ../../../../trojita/src/Gui/ComposeWidget.cpp:515
#53 0x00000000004cf570 in Gui::ComposeWidget::qt_static_metacall (_o=0x350c320, _c=QMetaObject::InvokeMetaMethod, _id=5, _a=0x7fff837f7fe0) at moc_ComposeWidget.cpp:84
#54 0x00007f90d91d4ec1 in QMetaObject::activate (sender=0x2d85810, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7fff837f7fe0) at kernel/qobject.cpp:3539
#55 0x0000000000618d0f in Composer::Submission::failed (this=0x2d85810, _t1=...) at moc_Submission.cpp:177
#56 0x0000000000615b96 in Composer::Submission::gotError (this=0x2d85810, error=...) at ../../../../trojita/src/Composer/Submission.cpp:289
#57 0x0000000000618a41 in Composer::Submission::qt_static_metacall (_o=0x2d85810, _c=QMetaObject::InvokeMetaMethod, _id=6, _a=0x7fff837f8220) at moc_Submission.cpp:88
#58 0x00007f90d91d4ec1 in QMetaObject::activate (sender=0x3c1ede0, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7fff837f8220) at kernel/qobject.cpp:3539
#59 0x00000000005e7a1f in MSA::AbstractMSA::error (this=0x3c1ede0, _t1=...) at moc_AbstractMSA.cpp:133
#60 0x00000000005e6087 in MSA::SMTP::handleError (this=0x3c1ede0, err=QAbstractSocket::SslHandshakeFailedError, msg=...) at ../../../../trojita/src/MSA/SMTP.cpp:63
#61 0x00000000005e7d57 in MSA::SMTP::qt_static_metacall (_o=0x3c1ede0, _c=QMetaObject::InvokeMetaMethod, _id=2, _a=0x7fff837f8400) at moc_SMTP.cpp:54
#62 0x00007f90d91d4ec1 in QMetaObject::activate (sender=0x30c6e90, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7fff837f8400) at kernel/qobject.cpp:3539
#63 0x00000000005ee1cf in QwwSmtpClient::socketError (this=0x30c6e90, _t1=QAbstractSocket::SslHandshakeFailedError, _t2=...) at ./moc_qwwsmtpclient.cpp:251
#64 0x00000000005ee128 in QwwSmtpClientPrivate::onError (this=0x4044d90, e=QAbstractSocket::SslHandshakeFailedError) at ../../../../trojita/src/qwwsmtpclient/qwwsmtpclient.cpp:141
#65 0x00000000005f45f7 in QwwSmtpClient::qt_static_metacall (_o=0x30c6e90, _c=QMetaObject::InvokeMetaMethod, _id=16, _a=0x7fff837f8650) at ./moc_qwwsmtpclient.cpp:134
#66 0x00007f90d91d4ec1 in QMetaObject::activate (sender=0x3d71020, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7fff837f8650) at kernel/qobject.cpp:3539
#67 0x00007f90d9618cc1 in QAbstractSocket::error (this=<optimized out>, _t1=QAbstractSocket::SslHandshakeFailedError) at .moc/release-shared/moc_qabstractsocket.cpp:247
#68 0x00007f90d964755f in QSslSocketBackendPrivate::startHandshake (this=0x3902510) at ssl/qsslsocket_openssl.cpp:1281
#69 0x00007f90d9648a06 in QSslSocketBackendPrivate::transmit (this=0x3902510) at ssl/qsslsocket_openssl.cpp:1108
#70 0x00007f90d9641b09 in qt_static_metacall (_a=<optimized out>, _id=<optimized out>, _o=<optimized out>, _c=<optimized out>) at .moc/release-shared/moc_qsslsocket.cpp:98
#71 QSslSocket::qt_static_metacall (_o=<optimized out>, _c=<optimized out>, _id=<optimized out>, _a=<optimized out>) at .moc/release-shared/moc_qsslsocket.cpp:77
#72 0x00007f90d91d4ec1 in QMetaObject::activate (sender=0x30c7040, m=<optimized out>, local_signal_index=<optimized out>, argv=0x0) at kernel/qobject.cpp:3539
#73 0x00007f90d961b66f in QAbstractSocketPrivate::canReadNotification (this=0x34e5a50) at socket/qabstractsocket.cpp:654
#74 0x00007f90d9624931 in event (this=<optimized out>, e=<optimized out>) at socket/qnativesocketengine.cpp:1151
#75 QReadNotifier::event (this=<optimized out>, e=<optimized out>) at socket/qnativesocketengine.cpp:1148
#76 0x00007f90d9a7b794 in QApplicationPrivate::notify_helper (this=0x244c190, receiver=0x353cff0, e=0x7fff837fa130) at kernel/qapplication.cpp:4562
---Type <return> to continue, or q <return> to quit---
#77 0x00007f90d9a8085d in QApplication::notify (this=0x7fff837fa810, receiver=0x353cff0, e=0x7fff837fa130) at kernel/qapplication.cpp:3944
#78 0x00007f90d91bd70c in QCoreApplication::notifyInternal (this=0x7fff837fa810, receiver=0x353cff0, event=0x7fff837fa130) at kernel/qcoreapplication.cpp:946
#79 0x00007f90d91f2dc8 in sendEvent (event=0x7fff837fa130, receiver=<optimized out>) at kernel/qcoreapplication.h:231
#80 socketNotifierSourceDispatch (source=0x244fc80) at kernel/qeventdispatcher_glib.cpp:110
#81 0x00007f90d8921603 in g_main_dispatch (context=0x244eb00) at gmain.c:2539
#82 g_main_context_dispatch (context=0x244eb00) at gmain.c:3075
#83 0x00007f90d8921980 in g_main_context_iterate (context=0x244eb00, block=1, dispatch=1, self=<optimized out>) at gmain.c:3146
#84 0x00007f90d8921a6c in g_main_context_iteration (context=0x244eb00, may_block=1) at gmain.c:3207
#85 0x00007f90d91f389f in QEventDispatcherGlib::processEvents (this=0x2448990, flags=...) at kernel/qeventdispatcher_glib.cpp:424
#86 0x00007f90d9b3b156 in QGuiEventDispatcherGlib::processEvents (this=<optimized out>, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
#87 0x00007f90d91bbc92 in QEventLoop::processEvents (this=<optimized out>, flags=...) at kernel/qeventloop.cpp:149
#88 0x00007f90d91bc007 in QEventLoop::exec (this=0x7fff837fa390, flags=...) at kernel/qeventloop.cpp:204
#89 0x00007f90d91c1c65 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1218
#90 0x000000000044af8e in main (argc=1, argv=0x7fff837fa918) at ../../../../trojita/src/Gui/main.cpp:60

When you close the topmost error message, Trojita crashes.
Comment 8 Jan Kundrát 2013-06-18 10:28:47 UTC
Git commit 3995343662f660bbf3e353cacc1778662ccd0c16 by Jan Kundrát.
Committed on 17/06/2013 at 17:50.
Pushed by jkt into branch 'master'.

SMTP: do not signal success after hitting a failure earlier on

OK, this is some ugly code -- but it appears that it makes QwwSmtpClient more or
less work. That class is in a bad need for replacement :(.

The problem was that the onDisconnected event handler within the QwwSmtpClient
simply checked whether there are any pending commands, and if there are none, it
proceeded further towards emitting success even though the connection has never
succeeded. This is a wrong assumption in the client's code -- signalling success
just because the connection was severed before any command had a chance to be
queued is not what I would expect when using such component.

This code does *not* prevent duplicate signals about success, but I have yet to
see a situation where it breaks something.
REVIEW: 111073

M  +7    -2    src/MSA/SMTP.cpp

http://commits.kde.org/trojita/3995343662f660bbf3e353cacc1778662ccd0c16
Comment 9 Jan Kundrát 2013-06-18 10:28:47 UTC
Git commit 751a809d8fe30a7b4da64d68c32b698e4c47ea34 by Jan Kundrát.
Committed on 17/06/2013 at 17:49.
Pushed by jkt into branch 'master'.

tests: Make sure that a failed mail submission prevents proceeding any further

This, unfortunately, does not help with the QwwSmtpClient because it happily
emits done(true) even after hitting errors earlier in the process. This will be
addressed in the next commit.

M  +45   -0    tests/tests/test_Composer_Submission/test_Composer_Submission.cpp
M  +1    -0    tests/tests/test_Composer_Submission/test_Composer_Submission.h

http://commits.kde.org/trojita/751a809d8fe30a7b4da64d68c32b698e4c47ea34
Comment 10 Thomas Lübking 2013-06-18 11:37:13 UTC
You're getting multiple signals because the object is locked in the nested eventloop of ::exec()

The crash-cause here should be the (timered... tsss... ;-) delete-on-close-on-sent

Therefore I assume:

void ComposeWidget::sent()
{
   if (m_sentMail)
      return; // don't try to close twice when Qt exits a nested event queue

    // FIXME: move back to the currently selected mailbox

    m_sentMail = true;
    QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection);
}

should do, where QMetaObject::invokeMethod is simply the correct way to say QTimer::singleShot(0, this, SLOT(close()))

(QTimer actually catches this statement and avoids creating a timer and calls the above instead, because this "trick" to get a queued call spread so widely around ;-)
Comment 11 Jan Kundrát 2013-06-18 12:34:12 UTC
(In reply to comment #10)
> You're getting multiple signals because the object is locked in the nested
> eventloop of ::exec()

Sort of -- the QwwSmtpClient also happened to emit failure, followed by emitting failure once again, followed by signaling success. That is quote obviously wrong. You are right that the nested event loops brought havoc to this. I wonder if we could get rid of all nested event loops, eventually, but that's for another bugreport. Patches welcome :)
Comment 12 Nicolás Sirolli 2013-06-18 12:41:03 UTC
Thanks to both of you! Please, let me know if I can be of any help.
Comment 13 Jan Kundrát 2013-06-18 13:33:44 UTC
Nicolas, could you please check whether the updated trojita-nightly (git.1371551157-105.1 or newer) fixes the problem for you?
Comment 14 Nicolás Sirolli 2013-06-18 14:09:21 UTC
Yes, it does!
Comment 15 Thomas Lübking 2013-06-18 17:51:38 UTC
(In reply to comment #11)

> You are right that the nested event loops brought havoc to
> this.
If it wasn't there the additional signal wasn't mapped because the object was destroyed. But flushing the signals after the nested event loop exits breaks that conceptual protection. (Of course the sender should not signal nonsense in the first place but the crash occurs due to signal handling across nested event loops)

> I wonder if we could get rid of all nested event loops, eventually,
It is possible, but you've of course to add a slot for every dialog response handling you're currently doing inline (what looses you the original function and eventually object context)

The nested eventloops are often used because they provide a very convenient solution here  - with the risk of unpredicted state changes interim :-(