[ofa-general] Re: [PATCH] infiniband-diags: Fix memory leaks on IBERROR and IBPANIC
Jason Gunthorpe
jgunthorpe at obsidianresearch.com
Fri Mar 13 09:37:54 PDT 2009
On Fri, Mar 13, 2009 at 07:31:24AM -0400, Hal Rosenstock wrote:
> > When you care about stuff like this is if you are making functions
> > that don't have the luxury of calling exit/abort/etc, like in the
> > kernel or in some kind of RTOS environment - but in that situation it
> > is exit that is forbidden and proper resource clean up and error code
> > returning is just a consequence of getting rid of exit.
>
> That's not true in a number of RTOSs I've worked with in the past
> (vxWorks is the first one which comes to mind).
vxWorks doesn't have processes, that they have a library call called
'exit' that happens to work like thread_exit doesn't matter one bit,
you still can't call it and you still have to do proper resource clean
up and error unwind by hand.
It is just plain impossible to call exit/assert/abort from a library
and get proper resource clean up in an environment without
processes. Worrying about a few extra malloc the library may have made
while a call is running is pointless because you are ignoring all the
mallocs the calling program has done that won't get unwound.
Either free absolutely *everything* by guaranteeing that every library
call returns back to the caller - or don't: call exit and require your
library run in an environment with processes. Mixing the two
approaches is pointless and confusing.
Jason
More information about the general
mailing list