Re: Stack corruption and memory leak problems in c++/Fortran application



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

.



Relevant Pages

  • Re: GCC front-end for FORTH?
    ... more or less the same as generating C from Forth and then compiling ... No, of course not, but Java's stack is local to the function, and Java ... and the particular calling conventions. ... I guess this question amounts to "is it possible to stop the back-end ...
    (comp.lang.forth)
  • Re: Making C better (by borrowing from C++)
    ... This means that the called function cleans up the ... >> stack, i.e. adds to the stack before returning the space allocate ... different calling conventions automatically. ...
    (comp.lang.c)
  • Re: Unsigned 32 bit
    ... I see you are dabbling with MASM ... about changing 'PASCAL' to 'C' in any calling conventions. ... callee cleaning up the stack ...
    (microsoft.public.vb.general.discussion)
  • Re: Parameter Overflow Attack?
    ... >:pushed on to the stack in reverse order, ... However, in my defence, I was using the term "standard C calling ... The SGI ABI provides the same resiliance against too many parameters as ... what I described as the standard C calling conventions. ...
    (comp.security.misc)
  • Re: GCC front-end for FORTH?
    ... more or less the same as generating C from Forth and then compiling ... No, of course not, but Java's stack is local to the function, and Java ... to use the usual calling conventions. ... M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html ...
    (comp.lang.forth)