GAH! WTF?

Started by
25 comments, last by d000hg 19 years, 8 months ago
In VC6, you can use /F for the compiler or /STACK for the linker. Default is 1MB.
Advertisement
If the problem didn't arise before the code changes, then the new code is at fault. Check it. Check it for dangling pointers, array out-of-bounds etc. Debug. Step through your code section by section until the error occurs. Check the section.
Well dufus, next time use CVS, Perforce, Source Safe, etc.
Quote:Original post by Anonymous Poster
Well dufus, next time use CVS, Perforce, Source Safe, etc.


Well doofus, at least spell your insults correctly. ;) Anyway, how will that help? He already said his code isn't the problem.
-~-The Cow of Darkness-~-
That wasn't an insult, it was term of endearment.
Gee, I think alot of you didn't even read my first post. I told you that I had a backup from 2 days ago that I know for a fact worked perfectly, I tried that and it gave me the same error.

I have a feeling that either my compiler or computer is f*cked up.

Mastaba, my code will most likely run on MSVC6, but I forgot to mention that the game uses Clanlib which I doubt you have.

Bugboy
EVERY time have see something like this in my game it related to some other piece of code that I changed and overran a buffer, or used a wild pointer and generally destroyed my own stack. Here is the method I devised to work though the problem:

1) Backup your whole source tree every time you open the editor. Just replace the icon with a link to the batch file that later starts the ide. Backup on load is a pain but for me a life saver.

2) Write a small utility to add date to a filename(rename). So, Shooter.zip becomes Shooter Sun Jul 18 17_15_01 2004.zip. Add this to the batch file above.

I have a copy of my code from every time I have opened the game source dating back for about 3-4 years. I can rebuild the whole game to any point in that history. I have added a few tweaks like using 7zip's 7z.exe and excluding files I don't need. In total I only have about 40mb in my backup directory. Each backup costs me about 300k of disk.

Dir /s > New.txt on new source tree vs old source tree...etc. Use something like windiff to compare the differences. There is probably a better way to do this. This will tell you all the files that changes. My code has 627 small files, isolating changes. Then do a diff on the files that are different.

Ok. That’s helps isolating change to certain files. Other things to check:

-Ensure that you don't have bad data, ie include your data files in the above backups and version checking. I spent all day looking for a bug in my TTF code only to discover that my menu configuration file specified the wrong TTF file(which was not a ttf file :) )

-Binary search your code. Partition problematic code in half, if you can comment out the roots of great chunk of code. Once a section is found to fail, Copy the bits up smaller and smaller until you can work out what part of your game you can comment out without causing the crash. I do this second as it's less methodical and less likely to produce results. Occasionally just commenting out a big hunk of code will hide a problem rather than isolate it.

-Always leave your code in a compiling and running state before changing more stuff. I have a horrid habit of starting to fix something small and reengineering 3-4 critical subsystems at once at the end of it. My code will often not compile for weeks. Don't do this. I'm an idiot.

I didn't intend to solve your problem rather show you how to stop wasting time on this later, all learnt by wasting my time...
Chris Brodie
Gimp, most of your suggestions just seemed too much effort or I didn't get them.

I did comment out large swaths of code and actually got some results.

First I commented out my entire main loop except where it flips the back buffer and cleared the screen. This actually got the program to work, but all I had was a blank screen. Then I uncommented the part where it draws the player and that worked too.

I uncommented the next line where it did a function call that checked if the player had collided with a tile and that brought back the error. The weird part is when I deleted everything in the function and had it return 0 it still gave me the error.

Just for the hell of it I'll post my functions code and see if anyone sees something wrong with it.
int tilecol(Csprite spr, int colt,float SCX, float SCY,bool ncol=false,bool bcol=false,bool youzs=false) {CL_Rect sprRect;CL_Rect tilerect;int tx;int ty;int bob=0;tx=int((spr.x)/32)+int(SCX/32);ty=int((spr.y)/32)+int(SCY/32);	for (nx = tx-1; nx<=tx+int(spr.width/32)+1; nx++) {for (ny = ty-1; ny<=ty+int(spr.height/32)+1; ny++) {if (nx>-1 && ny>-1 && nx<=NUMX && ny<=NUMY) {	if (ncol && til[nx][ny].col!=colt) {goto gai;}if (til[nx][ny].col==colt && ncol==false) {gai:	sprRect.top=spr.y;	sprRect.left=spr.x;	sprRect.bottom=spr.y+spr.height;	sprRect.right=spr.x+spr.width;	if (youzs) {	sprRect.top=(sh/2)-32+you.vy;	sprRect.left=(sw/2)-32+you.vx;	sprRect.bottom=(sh/2)+32+you.vy;	sprRect.right=(sw/2)+32+you.vx;	}	tilerect.top=(ny*32)-SCY;	tilerect.left=(nx*32)-SCX;	tilerect.bottom=32+(ny*32)-SCY;	tilerect.right=32+(nx*32)-SCX;	if (tilerect.is_overlapped(sprRect)) {	bob=1;	if (bcol) {		if (til[nx][ny].id>1 && til[nx][ny].id<5) { til[nx][ny].id++; if (til[nx][ny].id==5) til[nx][ny].col=false;}	}	//if ((tilerect.left+16)+(32/1.5)>(sprRect.left+(spr.width/2)) && (tilerect.left+16)<(spr.width/1.5)+(sprRect.left+(spr.width/2))) {bob=2;}	//if ((tilerect.top+16)+(32/1.5)>(sprRect.top+(spr.height/2)) && (tilerect.top+16)<(spr.height/1.5)+(sprRect.top+(spr.height/2))) {bob=5;}	}}}}}	return bob;}
Bugboy
One thing does occur - you're passing your Csprite by value, not reference. How big (memory usage-wise) is the sprite? Does it dynamically allocate its image buffers or store them as class member arrays? If the latter, you're passing a fkukload of data on the stack every time you call this function - try passing it by reference instead (change it to "Csprite& spr, ..." instead).

Plus make sure that you've correctly implemented your 'equals' operator and copy constructor, they will be being called and may be recursing.
Trying to grow the stack more than 4k at a time is a big nono, since that would touch the page after the guardpage in charge of growing the stack. And this is for some reason what seems to happen.
You could have a look at the prologue of the function, the first lines of it in asm, looking something like
push ebpmov ebp,espsub esp,<some value here>

If you're subtracting a large value from esp, you'd better have a look around for large arrays or objects declared locally.
If nothing weird shows up there, you could try writing your own prologue.
Declare the function using __declspec(naked), and in the beginning add the following
_asm {push ebpmov ebp,espsub esp,__LOCAL_SIZE  ; I think, it could be named something else, have a look at MSDN}


and before you return from the function
mov esp,ebppop ebpmov eax,[bob]ret


An remove the return bob, since that's handled in the epilogue.

Oh, and another thing. Could you please show me the callstack when the exception is thrown?

This topic is closed to new replies.

Advertisement