Fedora 9: Receiving "Segmentation fault" in running C/C++ codes,
Previously I was writing C/C++ codes in windows. Recently when I started to write codes under Fedora 9, I am getting a problem. The problem is that most of the times when I run my program, after compiling with GNU g++, it gives "Segmentation Fault" error. I looked around in books searching for the roots of this error. In a book, the writer told that this error error arises if we open too many files at the same time. But in my code I am not even opening or writing even to a single file.
I tried my best but still I am not able to debug this error. Can any humane expert out there help me out in this regard. I would really appreciate his/her effort.
Ehsan ul haq
Re: Fedora 9: Receiving "Segmentation fault" in running C/C++ codes,
A segfault has nothing to do with opening files; it means you've accessed memory you haven't allocated, or tried to write to an area of memory where you shouldn't. You need to look carefully at the code that is segfaulting - get a stack trace from the debugger, and see what your code is doing at the exact point the segfault happens, and try to think about how that line of code could be accessing wrong memory. Hint: "It can't, because the same code works on Windows" is not a good place to start. "It is" is far better.
|All times are GMT +5.5. The time now is 15:09.|