[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    RE: Crashes in today's snapshot
From:       "Glen Parker" <glenebob () nwlink ! com>
Date:       1999-05-31 8:43:46
[Download RAW message or body]

Argh!!!  Looks like a compiler bug, and it's all because I didn't upgrade to
egcs 1.1.1+ ;-(  (I think).  But at long last I understand what's been
causing the crashes.  It goes something like this...

-------------------
struct KEntryKey {
  QString   a;
  QString   b;
};

void function(QString group)
{
  KEntryKey  key = { group, QString::null };
}
-------------------

Initializing a struct in this way with const objects will cause the objects
within the struct to *not* be constructed properly, ie no ctor will ever be
called.  They will however be destructed properly.  This only occurs with
const source objects, non const objects will not produce this behavior, nor
does it appear that any call parameters produce it either.

This becomes especially problematic with QString's shared data architecture,
which is exactly what caused the crashes, when the shared data was
dereferenced more times than referenced, and deleted early.

So the short story is, never do that ;-)  Use QString() instead if you must
initialize structs in that style.

I've just committed the workaround, which is just more QString::null ->
QString() changes, but only where really needed.  I reverted all the
un-needed changes I made last time.

Glen

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic