Another Unaligned Access/Code Generation Question

Sergey Tikhonov tsv at solvo.ru
Fri May 23 06:59:04 UTC 2008


Hello Jay,

Jay Estabrook wrote:
> Hi again,
>
> In the current Fedora 8 Alpha distro, KDE is getting, I think, a LOT
> more use than ever before, due to the GNOME problems. Because of that,
> UAs in KDE apps are, or have become, the majority of UAs showing up
> in /var/log/messages.
>
> I've tracked down a single point of unaligned access in one of the
> kdebase libraries that is continually showing up, as it is called by
> MANY of the KDE applications, like kicker and konsole and such.
>
> It is located in code whose name, according to GDB, is:
>
> _ZNK14QLocalePrivate14doubleToStringEdiNS_10DoubleFormEij
>
> And yes, that is almost certainly in C++ code... ;-}
>
> The UA is always from an instruction like:
>
>      ldt     $f10,-5721(t0)
>
> where register "t0" holds an aligned address in the "gp" area, and thus
> the odd offset is what causes the UA.
>
> I tried both GCC -23 and -37, and there was no difference in code.
>   
Please, take a look at kde patches from AC3 distro.
I remember that some there in kde where was a double/float value defined 
as sequence of bytes in the middle of char
arrays definitions. Later on it was stored into a data section as 
unaligned. I remember adding some long dummy variable
in front of that to force the defined double to be correctly aligned.

As for dbus problem - I was using temporary volatile pointer to the 
passed structure (patches are in AC3 tree) and that forced the
compiler to generate the correct code.

I remember I discussed that problem sometime ago with some guy from 
debian and Richard (gcc alpha patcher).
It seems that in current case that gcc assumption might be correct - it 
expects that the passed pointer to that union is aligned.
At it is supported by declaration of that function. That problem is that 
the caller assigns value to that pointer just from some data it has
(I guess some buffer received over network if I remember correctly).
To make it to work correctly it is necessary to use temporary structure 
on caller side and do byte copy of data into it and then call our
"problem" method or teach the method to not assume that pointer is 
properly aligned.

Again, I remember fixing most of the UAEs during AC2/AC3 preparations.

Thank you,

-- 
Sergey Tikhonov

Head, R&D department
Solvo Ltd.
Saint-Petersburg, Russia
http://www.solvo.ru
tsv at solvo.ru




More information about the axp-list mailing list