home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / aix / 8812 < prev    next >
Encoding:
Text File  |  1992-08-14  |  2.7 KB  |  60 lines

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