[Gc] libatomic_ops-7.2alpha4 alignment issue on x64 using Microsoft VC9 on WindowsXP64

Boehm, Hans hans.boehm at hp.com
Thu Mar 25 16:44:42 PST 2010


Can you use the debugger to check the stack pointer alignment in various frames on the stack?  It sounds like one of the functions on the stack is not preserving the 16 byte alignment, possibly because it's assembly code, or comes from a library compiled with a different compiler.

Hans

________________________________
From: gc-bounces at napali.hpl.hp.com [mailto:gc-bounces at napali.hpl.hp.com] On Behalf Of Pete Johnson
Sent: Thursday, March 25, 2010 5:19 PM
To: gc at napali.hpl.hp.com
Subject: [Gc] libatomic_ops-7.2alpha4 alignment issue on x64 using Microsoft VC9 on WindowsXP64

Hi

I've recently ported an application using the atomic ops calls from win32 to x64, and have run into an assertion issue. The code ran perfectly on win32.

AO_load() and AO_store() in aligned_atomic_load_store.h both have asserts in them which are confirming that the addresses passed are 8byte aligned (on x64). However, these asserts are failing in my code when passing the address of a stack based variable.

using the Microsoft __alignof() call confirms the address is 8 byte aligned, and that the sizeof() returns 8 too. However, the actual address is not divisible by 8 - the check in the assert

((size_t)addr & (sizeof(AO_t) - 1))

gives a result of 4.

I'm perplexed by this - Microsoft state that on x64 the stack is 16 byte aligned. Although commenting out the asserts produces code that appears to function OK, I'd sleep more easily if there was some rational explanation of this. Can anyone help?

Many thanks.

Pete
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://napali.hpl.hp.com/pipermail/gc/attachments/20100326/a4a8b951/attachment.htm


More information about the Gc mailing list