crash in QMutex::lock / IndexedString constructor

Stephan Diederich stephan.diederich at googlemail.com
Tue Jun 2 07:24:39 UTC 2009


On Tue, Jun 2, 2009 at 12:13 AM, Andreas Pakulat <apaku at gmx.de> wrote:
> On 01.06.09 22:06:32, Stephan Diederich wrote:
>> Hi,
>>
>> I played a bit with (building) KDevelop4 beta3 on OSX today. Both
>> kdevplatform and kdevelop are from the beta3 tarballs.
>> Unfortunately KDevelop crashes right on startup. CrashReporter log is attached.
>> As one can see in the bt, the crash happens in static initialization.
>> IndexedString uses the following global in it's QString constructor:
>> RepositoryManager< IndexedStringRepository >
>> globalIndexedStringRepository("String Index");
>> which may, or may not be initialized at that time.
>>
>> moving that global into an accessor like this:
>> namespace {
>>   RepositoryManager< IndexedStringRepository >&
>> getGlobalIndexedStringRepository(){
>>     static RepositoryManager< IndexedStringRepository >
>> globalIndexedStringRepository("String Index");
>>     return globalIndexedStringRepository;
>>   }
>> }
>> fixed it.
>
> We already moved other global statics into such accessors due to problems
> with other compilers than gcc 4.3 on linux (msvc for example) or even with
> gcc on linux. The problem is simply that there's no guarantee on the order
> of creation of global statics.

Yep, compilers can't be blamed. Just try to avoid the global. C++ FQA
lite has a nice entry:
http://yosefk.com/c++fqa/ctors.html#fqa-10.12

> However as I don't know the code very well I suggest to wait for a few days
> for an answer from David Nolden, before comitting this (you had commit
> access right?).

Sure, there's no hurry.

cheers,
stephan




More information about the KDevelop-devel mailing list