[Openais] RE: Library core dump using evt.

Mark Haverkamp markh at osdl.org
Wed Jan 11 07:21:57 PST 2006


On Tue, 2006-01-10 at 17:19 -0700, Steven Dake wrote:
> Mark,
> 
> The patches generally look good, except for the SA_AIS_ERR_LIBRARY
> return codes.  I've very loath to use them if we don't have to.  Are
> they absolutely necessary?
I know,  but the specification doesn't say that SA_AIS_ERR_NO_MEMORY is
an expected return code.  How do you read the "Return Values" of the
spec?  Do they mean "These are the only returns codes that you will get"
or is it possible to get other ones?  Anyway, out of the codes specified
in the document it seemed the only one to fit. The others seemed pretty
specific to a particular problem.

Mark.


> 
> Regards
> -steve
> 
> 
> On Tue, 2006-01-10 at 10:44 -0800, Mark Haverkamp wrote:
> > On Tue, 2006-01-10 at 07:23 -0800, Mark Haverkamp wrote:
> > > On Mon, 2006-01-09 at 22:00 -0700, Steven Dake wrote:
> > > [...]
> > > > 
> > > > Mark,
> > > > In an OOM, I think the following line would cause some problems:
> > > > 
> > > >    hl = malloc(sizeof(*hl));
> > > >     edi->edi_hl = hl;
> > > >     hl->hl_handle = *eventHandle;
> > > > 
> > > > no check for zero return from malloc.
> > > 
> > > Yes,  I try to remember to do that everywhere.  Sometimes when I am
> > > coding away I forget a check :-)
> > > 
> > > Thanks, I'll fix that and check all the other malloc calls too.
> > > 
> > 
> > I looked at the evt library for malloc checks and came up with some
> > patches.
> > 
> > 1) evt_lib_alloc.patch
> > 2) evt_make_event.patch
> > 3) evt_chan_open.patch
> > 4) evt_attr_get.patch
> > 
> > 1) This fixes the handle leak on failure, the malloc check for hl and
> > removes the redundant memset when creating a handle.
> > 
> > 2) Check malloc return and handle destroying and freeing the event on
> > failure.  The event destructor will handle freeing any already allocated
> > memory.  This is called by saEvtDispatch which doesn't return
> > SA_AIS_ERR_NO_MEMORY, so I am returning SA_AIS_ERR_LIBRARY.
> > 
> > 3) Check malloc return on hl data structures.
> > 
> > 4) Check malloc return and back out previous mallocs before returning an
> > error.  Since saEvtEventAttributesGet doesn't return
> > SA_AIS_ERR_NO_MEMORY, I return SA_AIS_ERR_LIBRARY.
> > 
-- 
Mark Haverkamp <markh at osdl.org>




More information about the Openais mailing list