Re: Global Variables Being Overwritten



"jgurtner" <jgurtner@xxxxxxxxxxx> wrote in message
news:1149033509.463217.49670@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
BINGO! Thanks a million!

you wrote:
"Some suggestions:
- Check your stack placement. Make sure it's not colliding with data
space. "

My compiler automatically placed the stack right in the middle of my
data. The stack was set to 80 bytes. I reset the size to 255 bytes
and the compiler moved it out in the open away from my other data.
(Not an major issue, but still not sure how to specify the exact
placement of the stack with my compiler).

Now the stack has plenty of room to expand!

Thanks again!

Excellent - glad to have been of service.

FWIW: I sometimes implement a "stack trap" - meaning that I assign a (small)
no-man's-land between stack and data, write some magic numbers there at
startup, and periodically check that the values have not been corrupted. If
they have been, I shout and wave... and then usually reset, since there's
not much point in continuing with corrupted data and/or stack... This is
useful in development for obvious reasons, but also in production, where the
idea isn't so much to catch bugs (there shouldn't be any!) but to catch a
runaway CPU... (I also always use a hardware watchdog too, but that's
another story...)

Steve
http://www.fivetrees.com


.



Relevant Pages

  • Re: Do buffers always start with the lowest memory address being the first element?
    ... > The C standard does not assume a downward-growing stack, ... > an upward-growing stack. ... C allows but does not require that the array produced ... > machine depends on both the C compiler and the machine. ...
    (comp.lang.c)
  • Re: switch statement, was compiler, status...
    ... Primary Register, Secondary Register, ... Stack, and abit of storage does it. ... This version of Small-C is copyrighted as a revision to Ron Cain's ... Croatia) is "Calculator Compiler" by Senko Rasik. ...
    (alt.lang.asm)
  • Re: subroutine stack and C machine model
    ... On a typical system the stack on entry to the function looks like this ... balance to specify the order of evaluation). ... compiler developer to find out when code can be moved around. ... I think the Standards people used compiler optimization as an excuse ...
    (comp.lang.c)
  • Re: back online again...
    ... really "acceptable") convention. ... stack machine, but the design ... target with my compiler (may need a different name for this though, ... most of this code is not likely to ever go to object files anyways... ...
    (alt.lang.asm)
  • Re: 2.6.25-git2: BUG: unable to handle kernel paging request at ffffffffffffffff
    ... since the compiler is totally free to spill and reload the local variable ... So forget about the prefetch, ... variable onto the stack, since it did that volatime memory access through ... the insane "store and immediately reload from ...
    (Linux-Kernel)