Monday, September 1, 2008

segmentation fault in linux/unix

A wired error happened today when I am trying to run a gcc complied application.
"Segmentation fault" happened in the least expected place (at least according to cout, it paused), so I tried very hard to
modify this bit of code in many ways. I couldn't solve the problem until I tried gdb.
After reading wikipedia for the simplest way of using gdb, and few other articles on the web, I start to debug the code.
I find that the application had a bug in one line, which is way below the code that I was messing around. 
How stupid I am... I should know that the application is still running and cout just haven't finish printing.....
I should have turn to debugging straight away because this is c++, not c#.

Conclusion: Never trust manual debug using cout.

No comments: