Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Stack problems

This topic is 5393 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post

Link to post
Share on other sites
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?

Share this post

Link to post
Share on other sites
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.


Steve AKA Mephs

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!