[Bug 160284] bad mmap causes cores in KPCMemoryDevice

Michael Pyne mpyne at purinchu.net
Tue May 27 05:11:51 CEST 2008


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=160284         




------- Additional Comments From mpyne purinchu net  2008-05-27 05:11 -------
Created an attachment (id=24962)
 --> (http://bugs.kde.org/attachment.cgi?id=24962&action=view)
Make data after header properly aligned.

A crash was reported on kde-devel due to unaligned memory access to what is
basically a pointer + mSizeEntryOffset.

Any kind of pointer dereference should either be through aligned memory, or you
should handle yourself since some architectures cannot handle unaligned memory
access.  Architectures that can handle will generally receive a significant
speed boost if you ensure all memory accesses are aligned.

The compiler will align data entries in a struct for you unless you tell it not
to so what I tried doing at first was to make the kpc_magic part of a anonymous
struct with the character string inline (but I couldn't get it to work).

Instead this patch adds padding after the magic and version data such that the
header takes up some multiple of sizeof(void*) bytes, which should make the
subsequent data get correct pointer alignment.

I haven't combed through the code to see how many other memory access there
are, but if there are more we may need to fix those too.

Please test this patch, it works for me (and will bump the pixmap cache version
so if you revert this delete your icon cache) but x86 does not experience
crashes due to alignment in general so I'm not sure if this is sufficient.


More information about the Kdelibs-bugs mailing list