Re: Stack corruption and memory leak problems in c++/Fortran application
- From: glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
- Date: Wed, 31 Oct 2007 06:46:34 -0800
Louis Krupp wrote:
(snip)
This is a wild guess:
The type of strlen() is 'size_t' instead of 'int'. On a 64-bit system, strlen(code_menu) could be using eight bytes.
Fortran could be expecting a 4-byte string length as the last argument. On a little-endian system like a PC, the string length is in the first four bytes, so the subroutine sees the right value. However, when the subroutine exits, it cuts back the stack as if the string length had used only four bytes, and the high order four bytes of the string length are being left on the stack. This could be why you're seeing increments of four bytes of memory usage and an eventual stack overflow.
Interesting idea. We should really know the actual calling sequence,
but it is usual for C to have the caller pop the stack. That tends
to be required for varargs functions, but it is usual to do it for all.
-- 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
- Stack corruption and memory leak problems in c++/Fortran application
- Prev by Date: Re: memory leak after calling a fortran function
- 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
|