[OPEN-ILS-DEV] Re: PATCH: bzero is deprecated and unnecessary
Mike Rylander
mrylander at gmail.com
Sun Sep 30 15:32:54 EDT 2007
On 9/30/07, Dan Scott <denials at gmail.com> wrote:
> On 30/09/2007, David J. Fiander <djfiander at fastmail.fm> wrote:
> > >
> > > First, I wouldn't initialize the buffer with nuls. I'd initialize it
> > > with (for example) exclamation points, with perhaps a nul at the end.
> > > That way if a wayward pointer gives us a string of exclamation points,
> > > we'll have a better chance of recognizing the problem. A string of
> > > nuls is neither distinctive nor informative.
> > >
> >
> > I agree. A long time ago I used to use a debugging malloc library
> > that filled the buffers returned with '\001' bytes. It's amazing how
> > many bugs one finds that way.
> >
>
> Also agreed here - debug builds of a commercial product I worked on
> used the same approach, and it did turn up lots of uglies in unit
> tests that had been hidden by nul initialization.
>
I agree with all of this as well. As a beginning, I have applied
Dan's patches that remove memset where it's clearly superfluous and
use it in preference to bzero when pre-filling is the current
mechanism for avoiding garbage in a new buffer.
That's just the first step, of course, in a full-blown memory
management audit. Or maybe just a step before we can think about that
...
I'm going to work up a patch that implements Scott's suggested buffer
misuse detector and replaces all memsets with that. Any
objections/suggestions?
--
Mike Rylander
| VP, Research and Design
| Equinox Software, Inc. / The Evergreen Experts
| phone: 1-877-OPEN-ILS (673-6457)
| email: miker at esilibrary.com
| web: http://www.esilibrary.com
More information about the Open-ils-dev
mailing list