Recommended Posts

Hello. I have been writing a game using win32 as a rendering engine, but it seems that it bugs out on me. I am drawing a football field consisting of around 700 sprites, and on the 20th refresh the program crashes. The call stack reveals the following:

[frames below may be incorrect and/or missing, no symbols loaded for user32.dll]

I am not sure what relevant code to show, as the program is pretty big. The following is the drawing part of the game:

Please note that the refreshing is done only after a mouse click, thus after 20 clicks the program crashes. I am really at loss for what this bug can be. Am I doing something wrong or is it the .dll that's bugging out? Any help would be appreciated.

Share this post

Link to post

Share on other sites

I can't see anything obviously wrong there, though I'm not an expert on Win32.

Your best approach is to put breakpoints everywhere and find at exactly which line the program crashes.

I do notice you are creating a brush in draw() every time the function runs. You probably need to destroy the brush once finished with it, or store the brush and reuse it. If the draw() function is being called many times per frame it could be a serious memory leak issue. Again, I'm not an expert, it's just something that jumped out at me.

Also, one thing you may find really helpful for debugging is setting up a link to the Microsoft Symbol Server, as detailed here. That'll let you see what functions are crashing in the Windows core code, and how that code is referenced from your own; in that case it should have quickly revealed the handle leak.

0

Share this post

Link to post

Share on other sites

Yeah, it was the HBRUSH problem. I just brainless copied the code from somewhere, thinking that HBRUSH was some kind of structure, not a handle (should have seen the H in the beginning of the name). Thank you, both of you for the help.