[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde
Subject:    A quick segfault guide...
From:       "Brandon K. Matthews" <bmatt () devils ! eng ! fsu ! edu>
Date:       1999-03-10 23:29:07
[Download RAW message or body]


I've noticed people writing the list when a program segfaults (recieves a
Segmentation Violation signal). If they're using Linux or have and can use
gdb, they can help the developers (some). I've created a
"crash-course, one-use-only" step-by-step for seeing what went wrong.

Please, please, please, please, please, (if you would) only report the
segfault bugs on the latest (or recent) CVS versions. If it's a bug in KDE
1.1, chances are good that it's already been fixed. Also, (sorry to yell,
but..) ONLY REPORT SEGFAULTS THAT ARE REPRODUCABLE. For instance, it
immidiately dies upon startup, or it dies every time you click a certain
button... EVERY TIME (or most of the time).

I hope this helps the developers :-) I'm also making this mailing
available on da' web. It's at http://devils.eng.fsu.edu/~bmatt/segf.html
I request that anyone email *me* corrections if I've made a mistake.
Hey... and the "myapp" program is real... bonus points if you can guess my
processor type (easy).

The quote for the day is (see below for context):

  "No, he's mostly dead. He's not completely dead. There's
    a difference between mostly dead, and completely dead."
            -- Billy Crystal, "The Princess Bride"

Here goes...

------------

When a program is segfaulting on you, and you are running linux, try using
gdb. The output is insanely more useful than, "it's seg faulting on me".

***
note: text in []s is variable. "(gdb)" is the gdb prompt; you type in
whatever comes after it.
***

Here's what to type, and what you should see.
-=-=-=-

At the shell, run gdb on the offending program (mine is called "myapp")

 $ gdb [myapp]
 GNU gdb [4.17]
 Copyright [1998] Free Software Foundation, Inc.
 GDB is free software, covered by the GNU General Public License, and you
 are welcome to change it and/or distribute copies of it under certain
 conditions.  
 Type "show copying" to see the conditions.  
 There is absolutely no warranty for GDB.  Type "show warranty" for 
 details.  
 This GDB was configured as "[myproc-mydist-linux]"... 
 (gdb) 

Now you want 'myapp' to run. Tell it to do so: enter 'run' at the prompt.

 (gdb) run

The program will run as usual. In the case of an X application, the window
may appear, you may be able to do stuff, etc. Everything will run fine
until you cause it to core (which you can do, right? because it's a
reproducable bug, right?) An X app (when run in gdb) will not disappear
when it segfaults. Instead it will "pull a Windows" and stop responding to
anything (even redraw requests). That's because it's (mostly) dead as a
doornail (see quote).

When it does, you'll see something like this:

 Starting program: [/path/to/prog/myapp]

 [ normal program output, if any ]

 Program recieved signal SIGSEGV, Segmentation fault.
 0x[804858b] in [main] ()
 (gdb)

*** Remember, the text in []s is variable. ***

What you just saw was your program segfaulting. Now you want to inspect
the stack. Don't ask what it is, just do it ;-). Enter at the prompt:

 (gdb) backtrace 10

You'll see a bunch of garbage. (one man's garbage is another man's
treasure!) It will look something like (ignore the names, they're just an 
example):

 #0  0x[804854f] in [segfault] ()
 #1  0x[8048648] in [deep_12] ()
 #2  0x[8048634] in [deep_11] ()
 #3  0x[8048620] in [deep_10] ()
 #4  0x[804860c] in [deep_9] ()
 #5  0x[80485f8] in [deep_8] ()
 #6  0x[80485e4] in [deep_7] ()
 #7  0x[80485d0] in [deep_6] ()
 #8  0x[80485bc] in [deep_5] ()
 #9  0x[80485a8] in [deep_4] ()
 (More stack frames follow...)
 (gdb)  


That's the good stuff. That's the info you want to send to the list.
At this point, you can copy the backtrace and kill the program. You
*should* know how to copy the text (that's beyond the scope...). To kill,
simply enter "kill" and confirm. Then you quit.

 (gdb) kill
 Kill the program being debugged? (y or n) y
 (gdb) quit

Now you fire up your mail program, and email what you found. Here's a
*sample* format (with no offense to kmail, of course):

----------------------------------------
To: kde@lists.netcentral.net
From: joe_linux_user@example.com

Hi guys,

KMail has been crashing on me whenever I click the send button. I
followed the beautifully written gdb ultra-mini-guide and got this:

#0  0x40085658 in free ()
#1  0x400969b8 in __shtab ()
#2  0x40096902 in QButtonPress ()
#3  0x40100aa3 in KDoThatButtonThang ()
#4  0x402a4b44 in KMail_crash_that_proggie ()
#5  0x40300ff3 in main ()

Is there a buffer gone wrong or something?

Thank you,
 Joe Linux User
----------------------------------------

Ciao,
BKM

-----------------------------------------------------------------------------
   ... and on the seventh day,         |  Brandon Matthews - SysAdmin
      He exited from append mode...    |  <bmatt@devils.eng.fsu.edu>
                                       |  (850) 410-6415
-----------------------------------------------------------------------------


-- 
Send posts to:  kde@lists.netcentral.net
 Send all commands to:  kde-request@lists.netcentral.net
  Put your command in the SUBJECT of the message:
   "subscribe", "unsubscribe", "set digest on", or "set digest off"
PLEASE READ THE ARCHIVED MESSAGES AT http://lists.kde.org/ BEFORE POSTING
**********************************************************************
This list is from your pals at NetCentral <http://www.netcentral.net/>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic