Previous frame inner to this frame (corrupt stack?)

Moderator
Posts: 370
Joined: 2006.08
Post: #1
I keep getting this error message when I debug my program: "Previous frame inner to this frame (corrupt stack?)"
I have no clue what it means, but the program gets a SIGBUS error when I just normally run it, so obviously I'm accesing memory that isn't mine. I can not find this error, and neither can my teacher, so now I'm turning to you guys for help Smile
The link for the application is here: http://www.ghettointeractions.com/MMORPG.zip
When I run the Windows port of this code, the debugger seems to have problems deleting array of points called vertices[] in the ~shape destructor. When I put a breakpoint in the program when I debug it on my mac, is says that it doesn't like the point::setX() function, which I assume is because it's having problems with the vertices[] array. Either way, that seems to be where the problem lies, but it easily could be something else that is just causing it to act that way Sad
Thanks in advance guys Smile
-wyrmmage

Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
It *still* builds an application with a blank window...
If you want us to debug a crash, give us a program that crashes Rasp
Quote this message in a reply
Oldtimer
Posts: 832
Joined: 2002.09
Post: #3
You're dying during static initialization. I can't really see what the problem would be, but if you make line 6 in main.cpp:

game *theGame;


and then initializes it in main like so:
theGame = new game();

Then you will, if the problem doesn't solve itself, have a much better chance at hitting it with the debugger.

Ohwait, I just realized what it is:

In objectmanager's and in object's constructors, you're creating names. Look at the for loops: x <= 20. It should be <20, otherwise you'll trample memory, something that is exeptionally bad to do in constructors. Wink
Quote this message in a reply
Oldtimer
Posts: 832
Joined: 2002.09
Post: #4
Actually, the above goes for just about every for loop in your program. Wink
Quote this message in a reply
Moderator
Posts: 370
Joined: 2006.08
Post: #5
OneSadCookie Wrote:It *still* builds an application with a blank window...
If you want us to debug a crash, give us a program that crashes Rasp

heh, it DOES crash Rasp Or rather, it has a lot of SIGSEVs and a SIGBUS when I run it. It isn't supposed to display anything, it's an engine XD
-wyrmmage


Fenris:
Why is it trampling memory? I'm rather lost on that fact. Should I also make it < 20 for the destructor? I tried changing the <= 20 to < 20 in the constructor in game and objectManager, but still does not seem to fix the problem, and the debugger does not pick it up (I'm actually testing this code on Windows currently, but I'm pretty sure that it does not matter.

Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Quote this message in a reply
Moderator
Posts: 370
Joined: 2006.08
Post: #6
I tried changing it to game* theGame = new game(), but I still have problems when I delete it, like this: delete theGame;
seems a constructor is still deleting invalid memory.

Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #7
wyrmmage Wrote:heh, it DOES crash Rasp Or rather, it has a lot of SIGSEVs and a SIGBUS when I run it. It isn't supposed to display anything, it's an engine XD

It doesn't crash for me Rasp

And it can't possibly have more than one crash, the first one kills it dead Rasp
Quote this message in a reply
Moderator
Posts: 370
Joined: 2006.08
Post: #8
ok, after some modification to the constructor and destructor, I've gotten it working, it seems Wink When I get home, I'll try to transfer it on over to the mac...I'd still like to hear what exactly 'memory trampling' is, though Smile
Thanks guys,
-wyrmmage

Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Quote this message in a reply
Oldtimer
Posts: 832
Joined: 2002.09
Post: #9
Memory trampling means that you create twenty pointers: objects[20];
Then, you create pointers between i=0 and i <= 20, which means that you're actually accessing element no 20. That isn't part of the array, and so you are overwriting whatever is just after the array in memory. Chances are that it's just random memory (which is what's happening to OSC) or that it overwrites some really important data in memory (which is happening to you and me).

The quick-fix in these cases is to turn on GuardMalloc in the Debug menu and debug the application. Go grab a cup of coffee and wait for it to die.
Quote this message in a reply
Moderator
Posts: 370
Joined: 2006.08
Post: #10
I'll look up what GuardMalloc is, thanks Smile
That makes much more sense now that you explain it...I just assumed that when you said array[20], it meant that it was making 21 elements (since it normally starts at 0)...rather odd that is actually is making what I told it to XD
Anyway, thanks for the help guys...my mesh now works fine, and I can move on to texture mapping Smile.
Oh, speaking of texture-mapping, I really need some advice on texture-mapping meshes. I'm really not quite sure how it is normally done. Do you take a texture, slice it up, and then apply each triangle that I got from the texture onto the triangle on the texture map, or do you just load the texture and then cram it onto all of the triangles on the mesh?
Any links to this subject would be appreciated, and probably save you guys a lot of explaining ^_^
As I said, thanks Smile
-wyrmmage

Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Frame Based Animation Nick 6 3,713 Jan 27, 2007 06:25 AM
Last Post: 007gamer
  NSWindow frame message not returning correct values after moving the window Svarog 6 4,571 Jan 7, 2007 06:41 PM
Last Post: OneSadCookie
  Trouble with stack implementation ferum 6 3,012 Oct 16, 2006 09:53 AM
Last Post: akb825
  variable frame rate animation in Cocoa Damian 3 3,490 Jul 16, 2003 06:00 PM
Last Post: macboy
  Frame Rates Iceman 11 4,979 Jun 20, 2003 06:59 PM
Last Post: Iceman