Re: Stack corruption and memory leak problems in c++/Fortran application
- From: "James Van Buskirk" <not_valid@xxxxxxxxxxx>
- Date: Wed, 31 Oct 2007 12:40:53 -0600
"Louis Krupp" <lkrupp@xxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:13iguknhfk3p80a@xxxxxxxxxxxxxxxxxxxxx
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.
Whoah there, this is a case of the blind leading the blind. In 64-bit
Windows, the callee does not cut back the stack on exit. There is only
one convention, search for the file SWConventions.doc that got installed
on your hard disk, or http://www.agner.org/optimize/calling_conventions.pdf
or see if it's in the Programming with Mixed Languages chapter of Intel's
documentation set. The first four arguments are passed in registers,
and further arguments are passed on the stack. There is a 32-byte gap
on the stack between the return address and the first stack argument, and
the stack is aligned 8 mod 16 on procedure entry. All stack arguments take
up 8 bytes on the stack, otherwise the next argument would be misaligned.
If in doubt, disassemble caller and callee either via the debugger or
DUMPBIN /DISASM (equivalently LINK /DUMP /DISASM) and look at what the
two sides are actually doing.
--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end
.
- 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: Stack corruption and memory leak problems in c++/Fortran application
- Next by Date: Re: opening char variable data file
- 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
|