: I am new to unix programming and I am currently working on RedHat Linux
: 5.1.
i just installed that on my laptop, and i've been told that RH51 is a
disaster. if you can stand to do it, try downgrading to 4.2 or something.
: But anyway I'm writing a program to send out the invoices for a company
: and I access a database with the program. Anyway when I loop back
: through the program I get a segmentation fault.
: I ran gdb and this is what it gave me...
: Program received signal SIGSEGV, Segmentation fault.
: chunk_free (ar_ptr=0x400ff8a0, p=0x8053990) at malloc.c:2892
: malloc.c:2892: No such file or directory.
okay, when you run gdb, you need to type 'where' at the prompt. this will
tell you where (duh) your program bombed. compile everything with the '-g'
flag (stick it in your makefile, or just on the command line when you type
'cc' or 'gcc').
: BTW this is a C++ program...
C++? maybe you don't want to be using malloc(). C++ people usually like to
use new(). i have no clue if they're compatable.
: I'm thinking this is probably not enough info for anyone to adequately
: figure out what is wrong so just tell me what to send.
if you can't get anything to work, then you should use your program to
tell you what's going on:
stick fprintf(stderr, "program got this far...\n") lines all over the
place. consider using a log file for these things, too, if they become
too numerable.
every time you compare a pointer to something or try to dereference it,
test for == NULL. usually a segmentation fault comes from trying to
dereference a NULL pointer or other uninitialized pointer.
good luck,
-chris