Patch for memory leak in vfs_defaults.c

Timur I. Bakeyev timur at com.bat.ru
Fri Apr 6 22:50:48 UTC 2018


On 7 April 2018 at 00:41, Andrew Walker via samba-technical <
samba-technical at lists.samba.org> wrote:

> On Fri, Apr 6, 2018 at 4:55 PM, Jeremy Allison <jra at samba.org> wrote:
>
> > On Fri, Apr 06, 2018 at 04:40:44PM -0400, Andrew Walker via
> > samba-technical wrote:
> > > Hi all,
> > > I encountered an issue where several FreeNAS users on samba 4.7 were
> > > experiencing memory leak resulting in single smbd process consuming all
> > > available RAM and swap space. Disabling the getwd cache significantly
> > > increased rate of leak, and enabling widelinks / disabling unix
> > extensions
> > > made the leak apparently stop. Investigation indicated that the leak
> was
> > in
> > > vfswrap_getwd().
> > >
> > > The attached patch resolved the issue.
> >
> > Oh god that's *embarassing*. Looks like my fault too, sorry.
> >
> > Thanks very much for finding that.
> >
> > Can you try the attached patch instead and confirm it fixes it,
> > it's a smaller and simpler change.
>
> That is actually the first patch I wrote when I was debugging the issue. It
> definitely works. :)
> The more complex patch was for consistency with vfswrap_realpath(), but I
> am not partial to either fix.
>

Yes, while the fix is trivial by itself, it took a lot of time to locate
the leak and Andrew did a tremendous work to nail it and fix.

Finding the leak also showed us that there is no good tooling to track
memleaks in Samba, at least on FreeBSD. Both dmalloc and valgrind failed us
on various reasons and only jemalloc helped to confirm at that point, that
the right place was spotted.

With regards,
Timur Bakeyev.


More information about the samba-technical mailing list