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

  1. Newsgroups: comp.unix.aix
  2. Path: sparky!uunet!usc!wupost!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!vista.atmos.uiuc.edu!davidw
  3. From: davidw@vista.atmos.uiuc.edu (David Wojtowicz)
  4. Subject: Re: Debuging Segmentation Violation Fault
  5. References: <1992Aug14.040021.25316@mcs.kent.edu> <1992Aug14.121619.26071@watson.ibm.com>
  6. Message-ID: <BszBzw.MpE@news.cso.uiuc.edu>
  7. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  8. Organization: Atmospheric Science at Univ of Ill at Urbana-Champaign
  9. Date: Fri, 14 Aug 1992 15:21:30 GMT
  10. Keywords: Segmentation Violation
  11. Lines: 53
  12.  
  13. In article <1992Aug14.121619.26071@watson.ibm.com> lpickup@vnet.ibm.com writes:
  14. >In article <1992Aug14.040021.25316@mcs.kent.edu>, jhuang@Chaos.mcs.kent.edu (Jing Huang) writes:
  15. > [.stuff deleted.]
  16. >|>
  17. >|> segmentation violation in malloc_y at 0xd00d43f0
  18. >|> 0xd00d43f0 (malloc_y+0x2a8) 7c7c45aa       stsi   r3,r28,0x8
  19. >|>
  20. >|>      From these two lines, all I can guess is that the fault is related to
  21. >|> "malloc". But "malloc" is used more than dozens of times throughout the
  22. >|> program, how am I supposed to know "who steps on whose toe and where".
  23. >|>
  24. >
  25. > [.stuff deleted.]
  26. >
  27. >  Usually malloc fails when it can't honor your request for storage.
  28. >i.e. you've requested a huge amount of memory (or even worse, a
  29. >negative amount--which I believe translates into a huge amount as
  30. >well!).
  31. >--
  32.  
  33.  
  34. Its even worse than this.  Malloc is not failing,(i.e. returning a NULL)
  35. it is seg faulting!  This is a far more serious problem.  The classic
  36. thing that causes seg faults inside a malloc is overwriting some previously
  37. malloc'ed area.  For example if you malloc an array of size 80 and then
  38. write to array location 81 you've overwritten your malloc'ed space.
  39. This causes serious problems.  Malloc places indexes and pointers in the
  40. space around the area you malloc.  It uses these pointers to help it
  41. keep track of what's malloc'ed and what's not.  If one of these pointers
  42. is trashed it might send malloc on a wild goose chase and cause it to
  43. eventually seg fault.   Unfortunately it is over very difficult to
  44. detect the exact location of these types of errors, especially if
  45. the program is large and does lots of mallocs.  
  46.  
  47. The first thing would be to look at the new code added of course to
  48. see if the error is obvious there.  Then check writing to memory areas
  49. (assigning values to an array, etc.) that occurred not long before the
  50. seg fault happened.  If this fails you need a debugging malloc (a
  51. special malloc that helps to catch these kinds of errors)
  52. Unfortunately IBM provides no such beast but there are ones available
  53. though not readily.  Finally, a program like CodeCenter from
  54. Centerline software is very likely to help but unfortunately costs
  55. $3000/1 user license!  (Every time I say this a CenterLine employee
  56. responds justifying the cost...I guess it is a free market and they
  57. can charge whatever they want)
  58.  
  59. ---------------------------------------------------------------------
  60. David Wojtowicz, meteorological research programmer
  61. Atmospheric Sciences Dept, University of Illinois at Urbana-Champaign
  62. d-wojtowicz@uiuc.edu, davidw@vista.atmos.uiuc.edu
  63. ---------------------------------------------------------------------
  64.  
  65.  
  66.