home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.aix
- Path: sparky!uunet!newsgate.watson.ibm.com!yktnews!admin!watson!xanadu.btv.ibm.com!lpickup
- From: lpickup@xanadu.btv.ibm.com (Lance Pickup)
- Subject: Re: Debuging Segmentation Violation Fault
- Sender: @watson.ibm.com
- Message-ID: <1992Aug14.121619.26071@watson.ibm.com>
- Date: Fri, 14 Aug 92 12:16:19 GMT
- Reply-To: lpickup@vnet.ibm.com
- References: <1992Aug14.040021.25316@mcs.kent.edu>
- Organization: IBM Technology Products
- Keywords: Segmentation Violation
- Lines: 46
-
- In article <1992Aug14.040021.25316@mcs.kent.edu>, jhuang@Chaos.mcs.kent.edu (Jing Huang) writes:
- |> Dear netters, I have always wanted to ask this question. To me, the
- |> most horrifying error a program can have is "segmentation violation". I never
- |> have any clear idea about how to debug this kind of fault. Can someone give
- |> me some advice from his own experience on how to solve this fault?
- |>
- |> I have this HUGE C program (20,000 lines). Everything worked fine
- |> until the other day I added a few (about 10) lines to it. Then all of a sudden,
- |> it keeps giving me this "segmentation violation". I ran "dbx" to see if I can
- |> get some clue, it gave me something like:
- |>
- |> segmentation violation in malloc_y at 0xd00d43f0
- |> 0xd00d43f0 (malloc_y+0x2a8) 7c7c45aa stsi r3,r28,0x8
- |>
- |> From these two lines, all I can guess is that the fault is related to
- |> "malloc". But "malloc" is used more than dozens of times throughout the
- |> program, how am I supposed to know "who steps on whose toe and where".
- |>
- |> I am desperate. Could someone tell me what other things I should do
- |> beyond these two lines? Or maybe what books or manuals should I read to get
- |> more information? What do those address-like (?) numbers all mean?
- ...
-
- Jing,
-
- The next step inside dbx would be to use the t command to get a
- list of the traceback stack. The line you see above will be at the
- top, the function which called it will be on the next line, and so
- on. You will eventually see your functions in the traceback,
- and if you compiled with -g you can even see line numbers and
- parameters passed. This should point you to the line in your code
- which is calling malloc which fails.
-
- Usually malloc fails when it can't honor your request for storage.
- i.e. you've requested a huge amount of memory (or even worse, a
- negative amount--which I believe translates into a huge amount as
- well!).
- --
- ...Lance
-
- -----------------------------------------------------------------------
- Lance Pickup VNET/IBM Internet: lpickup@btv
- IBM/Vendor Systems Internet: lpickup@vnet.ibm.com
- Technology Products
- Burlington, VT Phone: (802) 769-7104 (tie 446)
- -----------------------------------------------------------------------
-