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