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

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:

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" );
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.