Thread: Linux segmentation errors

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    6

    Linux segmentation errors

    How do you deal effectively with Linux segmentation errors?
    They drive me crazy. There's no line number associated with
    them, so the error could be caused anywhere by anything in
    the code. I suspect bad pointers are the usual cause, but
    fixing them is a real headache and takes so much time!
    Is there a good method for fixing segmentation errors,
    that is, besides writing perfect code?

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    I often hear Valgrind and Electric Fence mentioned. A quick Googling found me these:
    http://valgrind.org/
    http://directory.fsf.org/ElectricFence.html
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    Also, try compiling your program with the -g option. Then when you get a segmentation fault, use gdb on the core file. e.g. $ gdb ./myprogram core
    If you understand what you're doing, you're not learning anything.

  4. #4
    Registered User
    Join Date
    Nov 2005
    Posts
    95
    You must learn to work with core files.
    core file is the process image at time of recvinig the signal
    seg fault.

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    6

    Linux segmentation errors

    Thanks for the help. But where do you go to learn
    more about core files? I've never worked with them before
    and I haven't seen much written about them.
    Is there a tutorial of faq somewhere on the internet?

  6. #6
    Registered User
    Join Date
    Nov 2005
    Posts
    95
    core file is the process image at time of recvinig the signal
    seg fault.
    Its very easy to look at the debuger manuall and learn how to work with
    core files.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WIN32 API and Linux... *shudder
    By parad0x13 in forum C++ Programming
    Replies: 4
    Last Post: 07-24-2008, 07:27 PM
  2. installing linux for the first time
    By Micko in forum Tech Board
    Replies: 9
    Last Post: 12-06-2004, 05:15 AM
  3. Linux for Windows!
    By Strut in forum Linux Programming
    Replies: 2
    Last Post: 12-25-2002, 11:36 AM
  4. Linux? Windows Xp?
    By VooDoo in forum Linux Programming
    Replies: 15
    Last Post: 07-31-2002, 08:18 AM
  5. linux vs linux?
    By Dreamerv3 in forum Linux Programming
    Replies: 5
    Last Post: 01-22-2002, 09:39 AM