Bug 75001 - crash on first display of any mail message
Summary: crash on first display of any mail message
Status: RESOLVED FIXED
Alias: None
Product: kmail
Classification: Applications
Component: general (show other bugs)
Version: 1.6
Platform: Compiled Sources Other
: NOR crash with 60 votes (vote)
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
: 75123 79274 79500 80693 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-02-11 21:06 UTC by Alexander Diemand
Modified: 2007-09-14 12:17 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Backtrace that kmail generates after crashing, Kde 3.2.1, OS X 10.3, Fink (2.83 KB, text/plain)
2004-03-31 04:35 UTC, Yuri Litvin
Details
Console output that kmail generates during the crash. (27.86 KB, text/plain)
2004-03-31 04:36 UTC, Yuri Litvin
Details
Email that makes kmail crash (103.91 KB, message/rfc822)
2004-03-31 04:37 UTC, Yuri Litvin
Details
patch that fixes (1.06 KB, patch)
2004-11-17 15:47 UTC, Benjamin Reed
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Diemand 2004-02-11 21:06:01 UTC
Version:           1.6 (using KDE KDE 3.2.0)
Installed from:    Compiled From Sources
Compiler:          gcc 3.3 APPLE version Darwin 7.2, OSX 10.3
OS:          Other

after starting up, I choose a message to display and ...

kmail:
**
** ObjectTreeParser::parseObjectTree( node OK, showOnlyOneMimePart: FALSE ) **
**
kmime_codec_qp.cpp:285: failed assertion `mBadChar == 0'
*** KMail got signal 6 (Crashing)
Comment 1 Ingo Klöcker 2004-02-12 10:38:23 UTC
Please attach the message to this bug report.
Comment 2 Ingo Klöcker 2004-02-13 10:22:41 UTC
*** Bug 75123 has been marked as a duplicate of this bug. ***
Comment 3 Arc C. 2004-02-17 19:08:34 UTC
Anyway I can help to troubleshoot this bug? I'd like to have kmail working on my machine too.
Comment 4 Alexander Diemand 2004-02-18 09:51:54 UTC
-I had to backtrack to KDE 3.1.x, there KMail works fine.
-[The message cannot be displayed, its soo private.]
-Will try again later with a clean recompile of KDE 3.2 from newest sources (CVS?), 3.1.x should be removed completely prior to that.
Comment 5 Ingo Klöcker 2004-02-18 11:14:50 UTC
A backtrace of the crash might provide some insights. You should compile with full debug information (i.e. configure with --enable-debug=full) in order to get a useful backtrace.

Also please try to create a non-private test message.
Comment 6 Arc C. 2004-02-18 23:41:15 UTC
Strange, but for me after re-compiling kdepim with full debug support, I got kmail come up without a problem. Can provide an output from 'kmail' command if someone is interested.
Comment 7 Yuri Litvin 2004-03-31 04:32:50 UTC
Still crashes in version 3.2.1, OS X 10.3, compiled from fink, same error as Alexander Diemand was experiencing... Specifically compiled kdepim and kdelibs with --enable-debug=full and it didn't stop crashing. Same email does NOT make kmail crash on gentoo box with 3.2.1 installed.

Including both trace, console output and email message that was making it crash

It seems to crash when displaying non-us emails and spam.
Comment 8 Yuri Litvin 2004-03-31 04:35:22 UTC
Created attachment 5471 [details]
Backtrace that kmail generates after crashing, Kde 3.2.1, OS X 10.3, Fink

This is the backtrace that kmail generates after crashing with signal 6

Error: kmime_codec_qp.cpp:285: failed assertion `mBadChar == 0'
*** KMail got signal 6 (Crashing)
Comment 9 Yuri Litvin 2004-03-31 04:36:25 UTC
Created attachment 5472 [details]
Console output that kmail generates during the crash.

Compiled kdepim and kdelibs with --enable-debug=full
Comment 10 Yuri Litvin 2004-03-31 04:37:39 UTC
Created attachment 5473 [details]
Email that makes kmail crash

Kde 3.2.1, OS X 10.3, compiled from source using fink
Comment 11 Christof Wolf 2004-04-09 22:25:21 UTC
I have exactly the same problem like Alexander. It looks like a problem with mimetypes.

ciao
chris


<-------snip-------konsole--------->
kmail: 
**
** ObjectTreeParser::parseObjectTree( node OK, showOnlyOneMimePart: FALSE ) **
**
kmail: partNode::findType() is looking at Text/Plain
kmail: partNode::findType() is looking at Text/HTML
kmail: partNode::findType() is looking at Text/Plain
kmail: 
**
** ObjectTreeParser::parseObjectTree( node OK, showOnlyOneMimePart: FALSE ) **
**
kmime_codec_qp.cpp:285: failed assertion `mBadChar == 0'
*** KMail got signal 6 (Crashing)
DCOP: unregister 'kmail'
KCrash: crashing... crashRecursionCounter = 2
KCrash: Application Name = kmail path = <unknown> pid = 16048
QSettings::sync: filename is null/empty
DCOP: register 'anonymous-16062' -> number of clients is now 1
DCOP:  'anonymous-16062' now known as 'drkonqi-16062'
DCOP: unregister 'drkonqi-16062'
DCOPServer : slotTerminate() -> sending terminateKDE signal.
klauncher: KLauncher::process ---> terminateKDE
Mutex destroy failure: Device busy
kdeinit: PID 16055 terminated.
kdeinit: terminate KDE.
DCOP: unregister 'klauncher'
DCOPServer : slotSuicide() -> exit.
ICE default IO error handler doing an exit(), pid = 16061, errno = 0
ICE default IO error handler doing an exit(), pid = 16057, errno = 0
<---------snip-------backtrace log-------------->
Reading symbols for shared libraries ................................................ done
Attaching to program: `/sw/bin/kmail', process 6699.
Reading symbols for shared libraries ++++++++++++++++++++++++++................................................................ done
0x900315a4 in wait4 ()
#0  0x900315a4 in wait4 ()
#1  0x0288b7c0 in KCrash::defaultCrashHandler(int) ()
#2  <signal handler called>
#3  0x90042aac in kill ()
#4  0x9009ec34 in abort ()
#5  0x018f9f18 in __eprintf ()
#6  0x018d0e44 in KMime::QuotedPrintableDecoder::decode(char const*&, char const*, char*&, char const*) ()
#7  0x018cdda8 in KMime::Codec::decode(char const*&, char const*, char*&, char const*, bool) const ()
#8  0x010d30e0 in KMMessagePart::bodyDecoded() const ()
#9  0x01187b40 in KMail::ObjectTreeParser::processTextPlainSubtype(partNode*, KMail::ProcessResult&) ()
#10 0x01182ca8 in KMail::ObjectTreeParser::parseObjectTree(partNode*) ()
#11 0x011884f8 in KMail::ObjectTreeParser::stdChildHandling(partNode*) ()
#12 0x011887bc in KMail::ObjectTreeParser::processMultiPartAlternativeSubtype(partNode*, KMail::ProcessResult&) ()
#13 0x01182ca8 in KMail::ObjectTreeParser::parseObjectTree(partNode*) ()
#14 0x010b6030 in KMReaderWin::parseMsg(KMMessage*) ()
#15 0x010b501c in KMReaderWin::displayMessage() ()
#16 0x010b4b40 in KMReaderWin::updateReaderWin() ()
#17 0x010bba70 in KMReaderWin::qt_invoke(int, QUObject*) ()
#18 0xefa359e0 in QObject::activate_signal(QConnectionList*, QUObject*) ()
#19 0xefa358c8 in QObject::activate_signal(int) ()
#20 0xefa4f018 in QTimer::event(QEvent*) ()
#21 0xef9f0ea0 in QApplication::internalNotify(QObject*, QEvent*) ()
#22 0xef9f0a98 in QApplication::notify(QObject*, QEvent*) ()
#23 0x0280a720 in KApplication::notify(QObject*, QEvent*) ()
#24 0xef9e2e5c in QEventLoop::activateTimers() ()
#25 0xef9acb20 in QEventLoop::processEvents(unsigned) ()
#26 0xef9ffb98 in QEventLoop::enterLoop() ()
#27 0xef9ffa84 in QEventLoop::exec() ()
#28 0x00002b4c in main ()
#29 0x00002628 in _start (argc=1, argv=0xbffffcf0, envp=0xbffffcf8) at /SourceCache/Csu/Csu-46/crt.c:267
#30 0x0000249c in start ()
Comment 12 Till Adam 2004-07-18 16:13:14 UTC
*** Bug 79500 has been marked as a duplicate of this bug. ***
Comment 13 Till Adam 2004-07-18 16:14:11 UTC
*** Bug 80693 has been marked as a duplicate of this bug. ***
Comment 14 Benjamin Reed 2004-09-14 20:59:53 UTC
I've been working on packaging KDE 3.3 for Fink, and this still occurs.  Is there anything I can do, debug-wise, that would help track this down?  I'm hesitant to release an update until we can figure this out...
Comment 15 Alexander Diemand 2004-09-15 08:30:25 UTC
Yes! I would like to come back and work with kmail.

The problem is with some hacks in the file:
KDE_CVS/kdepim/libkdenetwork/kmime_codec_qp.cpp

in member function: QuotedPrintableDecoder::decode where they try to filter out control chars by setting a flag named "mBadChar" to the value of the evil character and then make sure that this flag is still equal to '0' before any output (assert).

I never managed to get the CVS version to compile, so debugging was not that successfull. 
But if someone with a decent setup of KDE sources and experiences in this area could just try this and tweak the logic around "mBadChar"; it would be of tremendous help.
Could an overflow of an "unsigned char" assignment be the source of all problems?

Comment 16 Benjamin Reed 2004-10-22 13:57:36 UTC
I can confirm this still happens with KDE 3.3.1 on Mac OS X.

I tried looking into the kmime_codec_qp.cpp code but I'm not that much of a coder, it's beyond me.  =)  KMail is pretty useless currently on OSX with this error.  I don't suppose anyone has something to try?  I'd be happy to help test any changes...

I'd pay money to get this bug fixed, if that helps any.  ;)
Comment 17 Till Adam 2004-10-23 10:41:24 UTC
What happens if you simply comment out the assert( mBadChar == 0 ) in kmime_codec_qp.cpp?
Comment 18 Marc Mutz 2004-10-24 02:33:43 UTC
Ok, as already mentioned, I can't reproduce this on Linux/x86. If one of the reporters with a PPC (Mac) could run KMail from the debugger and set breakpoints on the three statements in kmime_codec_qp.cpp that assign to mBadChar (not counting the initialisation in the Decoder constructor), and execute the following commands in gdb if the breakpoint is hit:

gdb> print ch
gdb> print scursor-3
gdb> next # to execute the "mBadChar = ch" line
gdb> print mBadChar

This would be very much appreciated. Note: these lines are _never_ hit in my installation. You can also experiment with declaring mBadChar to be of type "unsigned char" instead of "char".
Comment 19 Marc Mutz 2004-10-25 13:24:52 UTC
On Sunday 24 October 2004 05:14, you wrote:
<snip>
> I'm compiling the latest 3.3.1 version so i can reproduce the crash.
> Would you mind posting step-by-step debugger instructions that you
> want us to do, because i'm not familiar with gdb at all... Or you can
> ssh/vnc to my box and try to do it yourself...
<snip>

In libkdenetwork/kmime_codec_qp.cpp, there are three lines in which "ch" 
is assigned to "mBadChar":
    mBadChar = ch;
Please precede each of those with these lines:
 kdDebug() << "Setting mBadChar to " << int(ch) << endl;
 kdDebug() << "here: \"" << QCString( scursor - 3, 10 ) << "\"" << endl;
and add
 kdDebug() << "mBadChar is really: " << int(mBadChar) << endl;
after the mBadChar = ch; line

Then recompile and attach the debug output to the bugreport.
If you get an compile error, add #include <kdebug.h> to the top of 
kmime_codec_qp.cpp.

Thanks,
Marc

Comment 20 Benjamin Reed 2004-10-25 15:58:14 UTC
I did your changes, but apparently it never got that far:

kmime_codec_qp.cpp:285: failed assertion `mBadChar == 0'

285 is the assert *before* the mInsideHexChar check.
Comment 21 Benjamin Reed 2004-10-25 17:47:06 UTC
also, changing it to unsigned char did not help.

Before that first assert, I put the kdDebug line, and ended up with this in the logs:

kmail: mBadChar is: 209
kmime_codec_qp.cpp:286: failed assertion `mBadChar == 0'
Comment 22 Luís Pedro Coelho 2004-11-09 19:54:50 UTC
*** Bug 79274 has been marked as a duplicate of this bug. ***
Comment 23 Benjamin Reed 2004-11-17 15:47:14 UTC
Created attachment 8314 [details]
patch that fixes

attached is a patch from Luis Pedro that seems to fix the issue (it works for
me, at least, on my 10.3 box with KDE 3.3.1)
Comment 24 Ingo Klöcker 2004-11-17 23:37:59 UTC
Hmm, if this patch really fixes the problem then this smells a lot like a compiler bug (on Mac OS X). I think I remember a similar fix quite some time ago. Since it's better to have an application that doesn't crash on some architectures than to save a few bits of memory, please commit the fix. I guess the second part of the patch (adding of assert(mAccu == 0);) isn't part of the patch, so please don't commit this part.

If someone with a PPC has time to investigate this problem it would probably be good to report this problem to the gcc people.
Comment 25 Brian O'Keefe 2004-11-18 18:41:54 UTC
How does one implement this patch? Are there some really simple 
instructions?
Thanks,
Brian
On Nov 17, 2004, at 7:47 AM, Benjamin Reed wrote:

> ------- You are receiving this mail because: -------
> You are on the CC list for the bug, or are watching someone who is.
>
> http://bugs.kde.org/show_bug.cgi?id=75001
>
>
>
>
> ------- Additional Comments From ranger befunk com  2004-11-17 15:47 
> -------
> Created an attachment (id=8314)
>  --> (http://bugs.kde.org/attachment.cgi?id=8314&action=view)
> patch that fixes
>
> attached is a patch from Luis Pedro that seems to fix the issue (it 
> works for
> me, at least, on my 10.3 box with KDE 3.3.1)
>

Comment 26 Tom Albers 2004-11-24 21:54:05 UTC
you have to checkout the source via cvs and apply the patch via patch < filename. After that you can start compiling. (see also: http://folk.uio.no/bro/anoncvs.html you ony have to build the module kdepim). But it can go terribly wrong, so use a test machine...
Comment 27 Till Adam 2004-12-12 14:24:39 UTC
CVS commit by tilladam: 

Since it appears to fix a crash on OSX and doesn't hurt much ...
BUG: 75001


  M +5 -5      kmime_codec_qp.cpp   1.14


--- kdepim/libkmime/kmime_codec_qp.cpp  #1.13:1.14
@@ -126,9 +126,9 @@ class QuotedPrintableDecoder : public De
           saw the first nibble '=X'
    */
-  const bool mQEncoding : 1;
-  bool mInsideHexChar   : 1;
-  bool mFlushing        : 1;
-  bool mExpectLF        : 1;
-  bool mHaveAccu        : 1;
+  const bool mQEncoding;
+  bool mInsideHexChar;
+  bool mFlushing;
+  bool mExpectLF;
+  bool mHaveAccu;
 protected:
   friend class QuotedPrintableCodec;