Problem Debugging C Program



I am having some problems debugging my program. I am getting a SIGSEGV.

I have a linked list. I am reading in data from a text file, storing the data in a linked list, and printing out the linked list.

I step through the program with GDB/DDD and everything seems to get parsed and stored correctly. Even when I print out my linked list, just before my printf statement I check the values in my list node and the values are fine. When I execute the printf, I get a SIGSEGV. I did a 'where' in GDB and got this:

Program received signal SIGSEGV, Segmentation fault.
0x006ab7ab in _IO_default_xsputn_internal () from /lib/libc.so.6
(gdb) where
#0 0x006ab7ab in _IO_default_xsputn_internal () from /lib/libc.so.6
#1 0x006a91d5 in _IO_new_file_xsputn () from /lib/libc.so.6
#2 0x006860a9 in vfprintf () from /lib/libc.so.6
#3 0x0068e2b7 in printf () from /lib/libc.so.6
#4 0x08049694 in print_list (l=0x8cf3170) at intrp_time.c:466
#5 0x0804990b in extract_records (f=0x8cf3008) at intrp_time.c:552
#6 0x08049afb in main (argv=Cannot access memory at address 0x39303a30
) at intrp_time.c:615

I am not sure what argv has to do with anything. Does anyone have any suggestions as to where I can start looking for this problem?

Thanks!
John
.



Relevant Pages

  • debugging c program
    ... I am having some problems debugging my program. ... Even when I print out my linked list, just before my printf statement I check the values in my list node and the values are fine. ... I get a SIGSEGV. ... I did a 'where' in GDB and got this: ...
    (comp.programming.threads)
  • Re: Problem Debugging C Program
    ... I am having some problems debugging my program. ... When I execute the printf, I get a SIGSEGV. ... You all think I'm paranoid, ...
    (comp.programming)
  • Re: Problem Debugging C Program
    ... I am having some problems debugging my program. ... Even when I print out my linked list, just) before my printf statement I check the values in my list node and the) values are fine. ... I get a SIGSEGV. ... You may have trashed your stack somewhere, causing the argv thingy. ...
    (comp.programming)
  • Re: signal.h
    ... now i know when i'm in gdb i can catch bugs but is there ... with gdb. ... could help in the general case of a SIGSEGV signal. ... saying that "implementation-specific extensions" could help ...
    (comp.lang.c)
  • Re: gcb output
    ... > I wrote a litte program, that generates a SIGSEGV after a while. ... > How could I find out, why exactly the problem occures? ... > gdb bt gives: ... You can use the gdb commands ...
    (comp.lang.cpp)