Stack problems

Started by
1 comment, last by Mephs 20 years, 1 month ago
Hi, I seem to be having what I can only imagine are problems with the stack in my terrain engine (using MSVC++). In my terrain engine, vertex and index buffers are being corrupted (and possibly other things I''m not aware of as it is hard to track down). I did have out of stack space errors, but increased the size of the stack with the /stack compiler option, which removed the errors. I then noticed that upon rendering with certain index and vertex buffers, I get an error, when I debug the app it basically shows that the variable holding the index buffer has been overwritten somehow, and I''m wondering if this relates to me allocating too many variables, etc on the stack? The thing is, I''ve stepped through the code, and the point at which the vertex and index buffers are overwritten changes depending on what I have allocated using ''new'', if I allocate less, then the vertex and index buffer array elements are overwritten later on in the code. I can only assume then that I am using too much stack memory or something of that nature and it is acting like an overfilled array and overwriting memory it shouldn''t be. Sorry if I''m making this hard to understand but I''m typing this in a hurry at work and don''t have access to my code here.... hope it does though and if anyone could explain what may be going on and how to solve it, that would be appreciated!! Cheers, Steve AKA Mephs
Cheers,SteveLiquidigital Online
Advertisement
I don''t have a clue what your problem is, but I do not think it has anything to do with allocating too much on the stack. You''d get an out of stack space error, not overwritten variables. Also, how are you allocating too much on the stack? Are you using a recursive function that recurses very deep? Or do you allocate alot of arrays statically inside a function?
My Page : http://acidbase.computed.net
Figured it out!!! Damnit sometimes it''s so easy to miss the little things. Basically, I''ve been creating a set of chunks in my terrain class, except I forgot that I had changed things so that instead of having 1 chunk, I was using an array of chunks, and had forgotten to update the
m_Chunk = new sChunk;

to what it should be:

m_Chunk = new sChunk[(y*m_NumMapsX)+x];

So I have been writing past the end of an array, as I''d been accessing my chunks via

m_Chunk[(x*m_NumMapsX)+y]->......blah blah

when it was only created as a single chunk!

Thanks for the answer anyhoo.

Cheers,

Steve AKA Mephs
Cheers,SteveLiquidigital Online

This topic is closed to new replies.

Advertisement