Re: Stack corruption and memory leak problems in c++/Fortran application
- From: glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
- Date: Wed, 31 Oct 2007 13:01:35 -0800
Chip Coldwell wrote:
Louis Krupp <lkrupp@xxxxxxxxxxxxxxxxxxxxxxx> writes:
The type of strlen() is 'size_t' instead of 'int'. On a 64-bit
system, strlen(code_menu) could be using eight bytes.
In fact, you are precisely right. On the Win64 architecture, size_t
is 64 bits, while both int and long are 32 bits. I'll bet this is the
cause of the four-byte memory leak.
It may be the cause of the problem, but is not likely a four
byte memory leak.
First, as James notes, the stack should be eight byte aligned
for 64 bit systems. Second, all the common C calling conventions
have the caller pop the stack. (It makes supporting C's
varargs functions much easier.)
Early 8086 calling conventions for Pascal and Fortran used a
callee-pops convention. (It saves one instruction per call,
using a special version of RET.) As C got more popular and
the need to call between languages increased, most converted
to a caller-pops convention.
-- glen
.
- References:
- Stack corruption and memory leak problems in c++/Fortran application
- From: Anndy
- Re: Stack corruption and memory leak problems in c++/Fortran application
- From: Colin Watters
- Re: Stack corruption and memory leak problems in c++/Fortran application
- From: Anndy
- Re: Stack corruption and memory leak problems in c++/Fortran application
- From: glen herrmannsfeldt
- Re: Stack corruption and memory leak problems in c++/Fortran application
- From: Anndy
- Re: Stack corruption and memory leak problems in c++/Fortran application
- From: Louis Krupp
- Re: Stack corruption and memory leak problems in c++/Fortran application
- From: Chip Coldwell
- Stack corruption and memory leak problems in c++/Fortran application
- Prev by Date: Re: opening char variable data file
- Next by Date: Re: Stack corruption and memory leak problems in c++/Fortran application
- Previous by thread: Re: Stack corruption and memory leak problems in c++/Fortran application
- Next by thread: Re: Stack corruption and memory leak problems in c++/Fortran application
- Index(es):
Relevant Pages
|
|