Debugger == God Mode?

SephirothSephiroth Fayetteville, NC, USA
OK I've got a problem that's REALLY ticking me off with my program. I have ported my engine over to OpenGL and when I use my debugger with the IDE project loaded, it runs perfectly windowed (go fullscreen and your system locks due to being debugged though). Now, when I shut down the IDE/project and run it from within explorer or by using run, it crates the window and right before the 3D view loads I get error 10H in 3dfxogl.dll and then an invalid page fault in kernel32.dll. Now why is it that it runs PERFECTLY in my debugger but will NOT run at all without being debugged?
Oh, if I close my project and run the debugger on it (or right click on the executeable in explorer and choose debug) it detects the crash and stops it's execution, but when I try to click the crash location it says "There's no line of code corresponding to this location". That's probably because the source isn't open! So what in the world is wrong here? I just don't get it.

-[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red]

Comments

  • SephirothSephiroth Fayetteville, NC, USA
    OK, I put a message box after every line in my code that draws the view and found the part where it is crashing. Here is the code:
    [code]
    for (int loop_m = 0; loop_m < numtriangles; loop_m++)
    {
    glBegin(GL_TRIANGLES);
    glNormal3f( 0.0f, 0.0f, 1.0f);
    glColor3f(1.0f, 0.0f, 0.0f);
    x_m = sector1.triangle[loop_m].vertex[0].x;
    y_m = sector1.triangle[loop_m].vertex[0].y;
    z_m = sector1.triangle[loop_m].vertex[0].z;
    u_m = sector1.triangle[loop_m].vertex[0].u;
    v_m = sector1.triangle[loop_m].vertex[0].v;
    glTexCoord2f(u_m,v_m); glVertex3f(x_m,y_m,z_m);

    glColor3f(0.0f, 1.0f, 0.0f);
    x_m = sector1.triangle[loop_m].vertex[1].x;
    y_m = sector1.triangle[loop_m].vertex[1].y;
    z_m = sector1.triangle[loop_m].vertex[1].z;
    u_m = sector1.triangle[loop_m].vertex[1].u;
    v_m = sector1.triangle[loop_m].vertex[1].v;
    glTexCoord2f(u_m,v_m); glVertex3f(x_m,y_m,z_m);

    glColor3f(0.0f, 0.0f, 1.0f);
    //Crashes on the next line (x_m=blah)
    x_m = sector1.triangle[loop_m].vertex[2].x;
    y_m = sector1.triangle[loop_m].vertex[2].y;
    z_m = sector1.triangle[loop_m].vertex[2].z;
    u_m = sector1.triangle[loop_m].vertex[2].u;
    v_m = sector1.triangle[loop_m].vertex[2].v;
    glTexCoord2f(u_m,v_m); glVertex3f(x_m,y_m,z_m);
    glEnd();
    }
    [/code]
    That shouldn't be too hard to follow. It causes the error 10H in 3DFXOGL.DLL, which means as much to me as if a dog was trying to tell me (no offense to those of you who might be dogs) :P. Anyways, "sector1" is a struct with x number of "traingle" structs that are made of 3 "vertex" structs (0-2, naturally). Why does the third set work perfectly when the IDE project is open but then fails every time when it isn't?? That's what blows my mind.

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red]


  • I can't help you dude, sorry... I just wanted to share the same feeling of (how do you call it?).. What the f**?

    This has happened to me more than one time.. For example, yesterday I finished a program, it was working perfectly well, everything was Ok, so I decided it was time to release it, so I changed configurations (i'm talking about MS VC++) to "Release" and compiled my program... What a surprise when I ran and used the program and it didn't worked well, it was doing weird things... Whatta ?.. It was working perfect in "Debug" version, I tried again and again, reinstalled Visual Stdio, and then got another PC and installed VC++ there, compiled, ...and same results!!!

    I still dont know what is going on, I just know that the .exe compiled with "Debug information" is working ok, but the .exe compiled without "Debug information" is doing weird things :-( ..

    Some weird things like this has happened to me before, and I have discoreved that to solve this, you have to rewrite your code to something else..

    Another example, on another program I was doing time ago, when I inserted a for() statement in a particular function, and I tried to debug the program the computer would just freeze... ? but it would not freeze if I wasn't debuggin... ?.. The solution?, I changed my for() with a while() and that's it....

    This is not only an MS VC++ issue, it also has happened with Borland..


    See ya!

  • The debug build makes the different code then release build and that is fine, because if there is no flaws in the program then everything will work fine in release mode too. Usually this problem is caused by the pointers which are pointed to garbage memory location - location which is OUTSIDE of your process memory space. Now when debugger runs the application it provides some handling for this problem, so memory is garbage, but it can be accessed - so no crash happens. When you run it as a released application and without debugger then these garbage pointers will be "firing"... Another thing you should know that memory allocation manager code is different in Debug and Release code - debug is more forgiving, but release code does not do any safeguarding, so you get your crashes... It may be other problems, of course. The only thing you can be sure about is that your code causes these problems, do not blame compiler for it...


  • When you crash in debugger and it says that there is no source code line available then just cancel this message and you will see some disassembled code. If you look at the call stack in Debug Windows - it will show the trace of calls - how the problem started - you can find in that list one of your functions... so double click on it and you should see gren arrow pointing to the NEXT line of code AFTER the line which cause the crash.


  • Thanks for your comments!..
    And yeah, I think you are right, I was already suspecting that I'm not coding very well ;-) jeje.. I need to do something about it..

    See ya!!

    - Jorge Gajn.


  • SephirothSephiroth Fayetteville, NC, USA
    : When you crash in debugger and it says that there is no source code line available then just cancel this message and you will see some disassembled code. If you look at the call stack in Debug Windows - it will show the trace of calls - how the problem started - you can find in that list one of your functions... so double click on it and you should see gren arrow pointing to the NEXT line of code AFTER the line which cause the crash.
    :
    :
    Oh blah, blah, blah! Lol! My memory code is just fine thanks to what you showed me a while back. It's actually a clipping problem in the 3D engine. I found it by moving the player start way outside the level and then disabling gravity (so he wouldn't fall into the abyss). Sure enough, when enough of the level went out of the view, CRASH! I'll start a post in my new board about clipping planes/regions and figure out how to fix it. Thanks for the help though.

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red]


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories