Jump to content
  • Advertisement
Sign in to follow this  
Silex

cout, the root of all evil

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

After days of thoroughly testing a project I'm ready to compile it in its final incarnation, so I remove all my debugging cout's. Segmentation Fault. Great. I put them back in, and I narrow it down to one cout that when it's there, whatever it prints (I've tried many, example "WHY, GOD, WHY?"), the segmentation fault occurs. I've never encountered this before, so I'm sort of clueless as to what this is a symptom of. Obviously I've messed up my memory somewhere, but why then would the program run fine with this stupid cout in it and not without? Anyone have any tips?

Share this post


Link to post
Share on other sites
Advertisement
Chris-
Yeah, I'm not saying it is, but the fact remains that my program executes flawlessly with the cout that isn't tied to any function (i.e. not getting its intput from any function), but it segfaults without it.

lonesock-
Trying that out now...

Share this post


Link to post
Share on other sites
Heh, I've had similar things occur with printf [in plain jane C, but the same applies...]. Essentially the cout isn't breaking your code, it's causing whatever buffer overflow you're causing [edit: in some probably wholy unrelated area] to overwrite something innocent [like the cout string] rather than something vital. The program will happily print garbage if the cout debugging message gets overwritten. Overwrite a pointer's value or something though, and things go downhill quickly.

[edit: the only real way to find the damn problem is generally to narrow it down to a cout that your program won't run without, then step through the code evaluating the cout. Once the output changes, that's where the bug is.

Needless to say, it's a pita.]

Share this post


Link to post
Share on other sites
Quote:
Original post by emileej
Man why dont I get interesting bugs like that?! :P


In the interest of maintaining the flame-free environment of this thread, I will suppress the obvious retort

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!