home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / os2 / programm / 4305 < prev    next >
Encoding:
Internet Message Format  |  1992-08-18  |  1.4 KB

  1. Xref: sparky comp.os.os2.programmer:4305 comp.lang.c:12488
  2. Newsgroups: comp.os.os2.programmer,comp.lang.c
  3. Path: sparky!uunet!stanford.edu!CSD-NewsHost.Stanford.EDU!Xenon.Stanford.EDU!amorgan
  4. From: amorgan@Xenon.Stanford.EDU (Crunchy Frog)
  5. Subject: Re: malloc causes a segmentation violation!?
  6. Message-ID: <1992Aug18.171440.349@CSD-NewsHost.Stanford.EDU>
  7. Sender: news@CSD-NewsHost.Stanford.EDU
  8. Organization: Computer Science Department, Stanford University.
  9. References: <1992Aug18.143135.6259@cc.tut.fi>
  10. Date: Tue, 18 Aug 1992 17:14:40 GMT
  11. Lines: 27
  12.  
  13. In article <1992Aug18.143135.6259@cc.tut.fi> 
  14.   mn87504@cs.tut.fi (Naatula Mika) writes:
  15.  
  16. >I wonder if this is a familiar bug to someone.
  17.  
  18. *All* bugs are familiar to me.  Solutions are harder.
  19.  
  20. >The problem is:
  21. >Sometimes my program causes a segmentation fault. If I drive it with
  22. >CVP I can find out (from calls sequence) that the error was caused by
  23. >malloc. To be exact, malloc calls an internal(?) function named
  24. >_searchseg() that fails. Any ideas what this function might be?
  25.  
  26. I had this problem before on another machine.  It turned out what
  27. I was doing was malloc'ing space that was too small, overrunning it
  28. and causing malloc to have a hissy fit.  I know you said you have
  29. checked your code, but I would look for a line like
  30.  
  31.     fred = (grumble *) malloc(sizeof(grumble *));
  32.  
  33. which should be
  34.  
  35.     fred = (grumble *) malloc (sizeof(grumble));
  36.  
  37. Typedefs could compllicate this search.  Good luck.
  38.  
  39. C Frog
  40.