On Oct 27, 2003, at 6:00 AM, Ronald Landheer-Cieslak wrote:


Q: what's the alignment I should use?
A: something smaller than the size of a pointer - like zero!
Result: part of - or everything of - the pointer can (and will) be overwritten
with user data. Thinking of it a bit more, I think a patch should be done to
XMLPlatformUtils::alignPointerForNewBlockAllocation that checks whether
XML_PLATFORM_NEW_BLOCK_ALIGNMENT < the pointer size, and if so makes it return
zero. The caller should check whether 0 was returned and not assume anything
about the pointer stored in the data area if it is. Like that, the semantics
become well-defined and the question gets a correct answer.



You've misread the code. The alignment has no effect on how much space is reserved for the block header. Space for the block header is allocated anyway. The alignment simply dictates the alignment of the data following the block header.


An alignment of < pointer size is perfectly legal for some architectures, which might allow alignment of 1, 2, etc.

A bogus configuration that specifies alignment of zero will:

(1) Not cause any overwriting of data.
(2) Will likely give an immediate divide by zero runtime error in execution as the expression
size_t current = ptrSize % alignment;
is evaluated.


(I've added a comment to the alignPointerForNewBlockAllocation code, noting that a XML_PLATFORM_NEW_BLOCK_ALIGNMENT declaration of zero is illegal).

 (1) Understand the problem
 (2) Architect a solution
We haven't done (1) yet, and we're arguing about a (2) that has no
purpose I can think of besides making things more complex.
I think we have done (1): I think we can both agree that
XMLPlatformUtils::alignPointerForNewBlockAllocation (which IMHO is badly named
because it doesn't actually align anything) shouldn't return false information
and, if it returns 0 (which it should on more occasions) that should actually
mean something useful.

I don't agree. alignPointerForNewBlockAllocation does not return false information, nor should it return zero, ever, unless input of zero is given to it. It works correctly.


The problem that needs to be understood is what is causing spurious crashes in your environment. You have guessed that an improper alignment specification for your architecture may be at fault. If that's proven to be the case then we can move forward to dealing with it.


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to