You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by bu...@apache.org on 2002/07/10 17:02:44 UTC
DO NOT REPLY [Bug 10648] New: -
IDDocumentImpl misaligned allocations on machines with a 64 bits 'long' type
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10648>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10648
IDDocumentImpl misaligned allocations on machines with a 64 bits 'long' type
Summary: IDDocumentImpl misaligned allocations on machines with a
64 bits 'long' type
Product: Xerces-C++
Version: 1.7.0
Platform: Other
OS/Version: Other
Status: NEW
Severity: Blocker
Priority: Other
Component: DOM
AssignedTo: xerces-c-dev@xml.apache.org
ReportedBy: benjamin.mironer@zslide.com
void * IDDocumentImpl::allocate(size_t amount)
aligns the adress it return to the size of void* (ie 32bits, generally)
see IDDocumentImpl.cpp line 892
size_t sizeOfPointer = sizeof(void *);
if (amount%sizeOfPointer!=0)
amount = amount + (sizeOfPointer - (amount % sizeOfPointer));
On some MIPS or IA64 machines, long is a 64-bits-long, 64-bits-aligned type
while void * is a 32-bits-long, 32-bits-aligned type.
Hence, if the object being allocated contains members of the type long (such as
an IDTreeWalkerImpl), these member will only be 64-bits aligned if the instance
itself is 64-bits aligned (the compiler takes care of the internal alignement
but the class needs to be aligned as well). If not, the constructor crashes
horribly.
So, I suggest using sizeof(long) instead of sizeof(void*) in
IDDocumentImpl::allocate(size_t amount) so it can run on 64 bits platforms.
This shouldn't cause any trouble on other platform (as long and int usually are
both 32 bits, and if not we'll only lose a little space).
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org