home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!elroy.jpl.nasa.gov!sdd.hp.com!saimiri.primate.wisc.edu!usenet.coe.montana.edu!news.u.washington.edu!uw-beaver!newsfeed.rice.edu!rice!abuhr
- From: abuhr@owlnet.rice.edu (Aaron M. Buhr)
- Subject: Re: Help me track down memory leakage
- Message-ID: <By75o7.BM8@rice.edu>
- Sender: news@rice.edu (News)
- Organization: Rice University
- References: <BxuLIr.DK@rice.edu> <1992Nov19.161411.25199@titan.inmos.co.uk> <By6G98.68L@rice.edu>
- Date: Tue, 24 Nov 1992 01:33:43 GMT
- Lines: 32
-
- In article <By6G98.68L@rice.edu> abuhr@owlnet.rice.edu (Aaron M. Buhr) writes:
- > As it turns out, I am having a strange error that I cannot figure
- >out. The dbg_malloc and dbg_free routines seem to be working fine, in
- >that they return pointers to valid-sized memory blocks and free those
- >memory blocks, and it seems that those blocks can be manipulated
- >directly or by some library calls (strcpy for example). However, for
- >some reason sscanf() returns a bus error when I try to use it on one
- >of the blocks the dbg_malloc() routines returned (the sscanf() works
- >fine with the regular C library malloc() routine). Here's the gdb
- >output:
-
-
- Many thanks to Jim Segrave, who pointed out that the size of the
- debugging block I was adding onto every allocated memory block had an odd
- size. This caused all returned memory pointers to point to odd addresses.
- The memory blocks worked fine with byte accesses, but as soon as I tried to
- manipulate the blocks as integers the program died with a bus error.
- Apparently, on Sun 4s all integer accesses must be word aligned. Changing
- the size of the filename space from 20 to 19 then decreased the size of the
- debugging block from 33 to 32, a nice, divisible-by-4 number, and caused the
- returned pointers to be properly aligned for integer accesses.
- I'm fixing up a bunch of other typos in the code, and when I'm done
- debugging and enhancing the package I'll probably post it to one of the
- .sources newsgroups. It's going to remain a simple, easy-to-use memory
- tracking routine, since there seem to be several large, full-featured
- products already available. Thanks again to all that helped me out on this.
- Hopefully I'll finally be able to get rid of all those darn memory leaks. :)
-
-
- Aaron Buhr
- abuhr@owlnet.rice.edu
-
-