views:

82

answers:

2

I am working on a Windows program codebase that has heretofore been 32-bit. I am trying to make this codebase 64-bit clean. Turning on “top down” allocations in the heap manager by setting the “AllocationPreference” registry value has been very helpful in turning up bugs where code was guilty of coercing pointers down to 32-bit values (such as ints) and back, thus loosing the most significant half of the pointer values on x64. In order to obtain similar debugging benefits I would like to force the virtual address of the stack for my process to be well above 2**32. Is there any way to do that on Windows Vista x64? For what it is worth, I am using Visual Studio 2008 to build this codebase.

A: 

I'm not sure about the case of Windows x64, but I'm pretty sure that with any 64-bit app the stack pointer would already start at a very large 64-bit address, with the application code at a low address and the heap somewhere in the middle. This is more or less the "traditional" layout of process memory. I know that on my MacBook here, I'm getting a stack pointer address well above a 32-bit limit. I would suggest that you write a small test application to print out the address of a stack-allocated variable, and that should give you a decent reference point of where the stack is located in virtual memory.

Joe M