Jump to content
  • Advertisement
Sign in to follow this  

Hunting a magic bug

This topic is 4729 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

I recently recompiled my entire program to make sure things were still sane. Now, it crashes on startup. However, if I open it in a debugger (gdb) it works fine. How would I find out what's causing this magic bug?

Share this post


Link to post
Share on other sites
Advertisement
Check your pointers. In debug mode, all memory pointers are NULL'ed out, so if do any delete's or operation with them, then those instructions may be ignored. In release mode, they will be some random value and will be operated upon, thus causing a crash. Make sure you are initializing them all to NULL.

Next, narrow down where the bug is. As in comment everything out and see if it works. If it does, then start adding things back in slowly as execution will allow (i.e. don't allow deinit code and not init [wink]) and see if you can find it.

If it should happen to crash before that, make sure you are using the right runtimes for your projects and all your libraries are compatible. Check over .DLL's as well.

Good luck!

Share this post


Link to post
Share on other sites
If this is a linux/unix platform try enabling core dumps and examine one of those:

ulimit -c unlimited
gdb program core.file

That way you can see the state of the program when it crashed. Isn't debugging fun. :) Isn't gdb great :)... Weeeee.

Share this post


Link to post
Share on other sites
Well, I just commented out a bunch of my main function and it worked. Uncommented stuff one at a time until I'd uncommented all the stuff, and it still worked. Apparently my computer was just throwing a hissy fit.

Sometimes programming just makes me angry...

Share this post


Link to post
Share on other sites
Sounds like a timing dependent problem, assuming the execution path is the same in the compiler and compiled exe. I had a problem once where a thread in the compiled exe would shut down faster than when connected to the debugger, resulting in some nasty stuff.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!