Summary: | KMail crashes everytime I close it. | ||
---|---|---|---|
Product: | [Unmaintained] kmail | Reporter: | Thomas Zander <zander> |
Component: | general | Assignee: | kdepim bugs <kdepim-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | crash | CC: | simonandric5 |
Priority: | NOR | ||
Version: | 1.7.50 | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: |
Valgrind output as requested in #1
kmime_use_staticdeleter.diff |
Description
Thomas Zander
2004-11-21 18:51:01 UTC
> at /home/zander/sources/kde/kdepim/libkmime/kmime_codecs.cpp:54
Looks like a miscompilation to me.
After a clean recompile of kdepim/libkmime, can you try with valgrind if it still happens?
valgrind --tool=memcheck --num-callers=50 kmail --nofork 2>&1 | tee log
Created attachment 8361 [details]
Valgrind output as requested in #1
I figured something like this when it first happened a week ago (when I moved
from BRANCH to HEAD), so I did a clean compile of the whole kdepim this
morning. But it still crashed.
So, here is the requested output. Note that at line 270 I wrote some comments.
Basically everything before is starting, and everything after is quitting.
I had this too, it stopped with HEAD as of today though > Created an attachment (id=8361)
> --> (http://bugs.kde.org/attachment.cgi?id=8361&action=view)
> Valgrind output as requested in #1
OK, this does look like a bug in the code indeed.
kmime_codecs.cpp:QMutex Codec::dictLock;
kmime_codecs.h: static QMutex dictLock;
Marc: no static object in libraries!
Solution: KStaticDeleter. Patch attached. I found another static object (the QAsciiDict)
so I changed that one for consistency (not strictly necessary as long as Codec classes
don't have Qt members, but this might change any time...).
Created an attachment (id=8362)
kmime_use_staticdeleter.diff
CVS commit by tilladam: Patch by David Faure introducing a static deleter to fix crashes on exit. BUG: 93675 M +23 -16 kmime_codecs.cpp 1.20 M +2 -2 kmime_codecs.h 1.19 --- kdepim/libkmime/kmime_codecs.cpp #1.19:1.20 @@ -41,4 +41,5 @@ #include <qcstring.h> +#include <kstaticdeleter.h> #include <cassert> @@ -50,22 +51,24 @@ namespace KMime { // global list of KMime::Codec's -QAsciiDict<Codec> Codec::all( 11, false /* case-insensitive */); +QAsciiDict<Codec>* Codec::all = 0; +static KStaticDeleter<QAsciiDict<Codec> > sdAll; #if defined(QT_THREAD_SUPPORT) -QMutex Codec::dictLock; +QMutex* Codec::dictLock = 0; +static KStaticDeleter<QMutex> sdDictLock; #endif void Codec::fillDictionary() { - all.setAutoDelete(true); + all->setAutoDelete(true); - //all.insert( "7bit", new SevenBitCodec() ); - //all.insert( "8bit", new EightBitCodec() ); - all.insert( "base64", new Base64Codec() ); - all.insert( "quoted-printable", new QuotedPrintableCodec() ); - all.insert( "b", new Rfc2047BEncodingCodec() ); - all.insert( "q", new Rfc2047QEncodingCodec() ); - all.insert( "x-kmime-rfc2231", new Rfc2231EncodingCodec() ); - all.insert( "x-uuencode", new UUCodec() ); - //all.insert( "binary", new BinaryCodec() ); + //all->insert( "7bit", new SevenBitCodec() ); + //all->insert( "8bit", new EightBitCodec() ); + all->insert( "base64", new Base64Codec() ); + all->insert( "quoted-printable", new QuotedPrintableCodec() ); + all->insert( "b", new Rfc2047BEncodingCodec() ); + all->insert( "q", new Rfc2047QEncodingCodec() ); + all->insert( "x-kmime-rfc2231", new Rfc2231EncodingCodec() ); + all->insert( "x-uuencode", new UUCodec() ); + //all->insert( "binary", new BinaryCodec() ); } @@ -73,11 +76,15 @@ void Codec::fillDictionary() { Codec * Codec::codecForName( const char * name ) { #if defined(QT_THREAD_SUPPORT) - dictLock.lock(); // protect "all" + if ( !dictLock ) + sdDictLock.setObject( dictLock, new QMutex ); + dictLock->lock(); // protect "all" #endif - if ( all.isEmpty() ) + if ( !all ) { + sdAll.setObject( all, new QAsciiDict<Codec>( 11, false /* case-insensitive */) ); fillDictionary(); - Codec * codec = all[ name ]; + } + Codec * codec = (*all)[ name ]; #if defined(QT_THREAD_SUPPORT) - dictLock.unlock(); + dictLock->unlock(); #endif --- kdepim/libkmime/kmime_codecs.h #1.18:1.19 @@ -57,7 +57,7 @@ class Codec { protected: - static QAsciiDict<Codec> all; + static QAsciiDict<Codec>* all; #if defined(QT_THREAD_SUPPORT) - static QMutex dictLock; + static QMutex* dictLock; #endif |