home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.sys.sun.admin:10666 comp.sys.sun.apps:3062 comp.sys.sun.misc:6441
- Newsgroups: comp.sys.sun.admin,comp.sys.sun.apps,comp.sys.sun.misc
- Path: sparky!uunet!cs.utexas.edu!uwm.edu!linac!att!mcdchg!laidbak!tellab5!sdc!scott
- From: scott@sdc.com (Scott Dunbar)
- Subject: Re: SEGV inside malloc() - This shouldn't happen!
- Message-ID: <1993Jan22.145011.8058@sdc.com>
- Originator: scott@minnie
- Sender: news@sdc.com (Netnews administrator)
- Nntp-Posting-Host: minnie
- Organization: sdc
- References: <mike.727636808@sdd.comsat.com> <MANN.93Jan21131125@emma.la.asu.edu>
- Distribution: na
- Date: Fri, 22 Jan 1993 14:50:11 GMT
- Lines: 31
-
-
-
- In article <MANN.93Jan21131125@emma.la.asu.edu>, mann@emma.la.asu.edu (Mark Mann) writes:
- > In article <mike.727636808@sdd.comsat.com> mike@sdd.comsat.com (Mike Stennett) writes:
- > > I am currently porting a program to a SparcStation 2 running SUN/OS 4.1.2.
- > > The program is written in C, Pascal, and Fortran. I am using all SUN
- > > compilers. My problem is I am getting segmentation faults within malloc.
- > > Now I have been writing C programs for 4 years and know that malloc should
- > > never cause a segmentation faults.
- > > [...]
- >
- > I have found that malloc() will fail with a segmentation fault when you
- > trash its tables. This usually happens when you write beyond the end
- > of an array. You haven't written out far enough to cause a segmentation
- > violation yourself, but just far enough to make garbage out of malloc()'s
- > tables. So... next time you call malloc() and it tries to access the
- > garbage you created... SEGV or somesuch.
-
- I agree fully. If you trash the heap, anything is possible with malloc()
- and free(). I would recommend the Purify product or something like it to track
- down these types of problems. With this it should take you very little time to
- find anywhere that you are writing over the end or before the beginning of a block
- of allocated memory. Purify helped me find many errors on a system that was
- ported from MS-DOS. The MS-DOS boxes would sometimes go into never-never land
- but basically were ok. The Suns SIGSEGV'd or SIGBUS'd all over the place.
-
- Good luck.
- --
- scott dunbar Systems Development Corporation
- scott@sdc.UUCP Chicago, IL
- ..uunet!tellab5!sdc!scott 312 739 1111
-