On Sunday 21 February 2010 05:20:22 pm Stefan Teleman wrote:
> Reading the code, running kdeinit4 through the debugger and at least
> obtaining a stack trace as to where the crash occurs might help.
The relevant code is like this (in qmutex.h, paraphrased here)
class QMutexLocker {
union { quintptr val; QMutex *mtx; } ;
QMutexLocker::QMutexLocker(QMutex *m) : mtx(m) {
assert (!(val & 1));
}
Elsewhere, there was code like this:
void unlock()
{
if (val & 1) {
val &= ~1;
mtx->unlock();
}
}
This bit-twiddles pointers through a union; I do not understand the
documentation of -xalias=compatible from the CC manpage to decide whether this
is allowed, or not (mention of unions there suggests to *me* at least that it
should be possible).
Using this code led to crashes because mtx was odd-aligned (pointing 1 past
the address of the mutex it's supposed to point to).
A solution that was applied earlier in unlock() was the following:
val &= ~1;
mtx=(QMutex*)val;
mtx->unlock();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: This is a digitally signed message part.
URL:
<http://mail.opensolaris.org/pipermail/kde-discuss/attachments/20100221/dbdb006e/attachment.bin>