🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer
Article #1089

Re: malloc causes a segmentation violation!?

#1089
From: Crunchy Frog
Date: Tue, 18 Aug 1992 17:14
27 lines
1437 bytes
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
Technical Details
Message-ID: <1992Aug18.171440.349@CSD-NewsHost.Stanford.EDU>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!CSD-NewsHost.Stanford.EDU!Xenon.Stanford.EDU!amorgan
References: <1992Aug18.143135.6259@cc.tut.fi>

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.os2.programmer,comp.lang.c
Path: arc1-ca.pugleaf.net!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