| | |
what is the best way to track segmentation fault errors
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jan 2005
Posts: 1
Reputation:
Solved Threads: 0
I am using linux.
I ve already tracked down the code, and I know which class instantiation is causing the problem. But I cannot go further than that, since the same code used to work before I did an upgrate of the opensource framework over which I am developing a new class (this one causing failure).
So is there a way to find out more about this problem? (I never used a debugger, I debug codes in the old style, printing messages...
)
Regards,
Luiz
I ve already tracked down the code, and I know which class instantiation is causing the problem. But I cannot go further than that, since the same code used to work before I did an upgrate of the opensource framework over which I am developing a new class (this one causing failure).
So is there a way to find out more about this problem? (I never used a debugger, I debug codes in the old style, printing messages...
)Regards,
Luiz
Generally, segmentation faults are because a pointer of yours is either NULL, or points to random memory (probably never initialized to anything), or points to memory that was deleted.
like:
like:
C++ Syntax (Toggle Plain Text)
void Test() { char* p1 = NULL; // initialized to null, which is good but not dereferencable on many systems char* p2; // not initialized at all char* p3 = new char[20]; // great, it's allocated delete [] p3; // but now it isn't anymore // now, referencing any of these variables could cause a segmentation fault. // here's some other possabilities: char* p4 = new char[20]; char c = p4[21]; // reference off the end. may depend on how FAR off the end // this one is more subtle, because we have 20 bytes allocated to a string // and we use strcpy to copy in a 20 byte string. But, wait! There is a // null terminator copied too, making it 21 bytes! This may not fail immediately, // but may fail later when you allocate more memory or delete this memory. strcpy( p4, "12345678901234567890" ); }
![]() |
Similar Threads
- mysterious segmentation fault (C)
- Segmentation Fault at fclose (C)
- Python 2.4.4, Segmentation fault (Python)
- segmentation fault: causes. (C++)
- segmentation fault (C++)
- segmentation fault (C)
Other Threads in the C++ Forum
- Previous Thread: Converting binary code to decimal value.
- Next Thread: Have an error in my program
| Thread Tools | Search this Thread |
api array based binary bitmap c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





