[lxc-devel] [PATCH lxcfs 4/5] cgfs: fix dorealloc's batch allocation

Mathias Gibbens mathias at calenhad.com
Fri Jan 8 21:24:52 UTC 2016


  Yes, the current git head for lxcfs (3beb534) works for me.

On Fri, 2016-01-08 at 21:13 +0000, Serge Hallyn wrote:
> It makes sense.
> 
> I was going to give this a few hours before releasing 0.16.
> 
> There's one more new commit in git head, can you try the very latest
> and make sure it works for you?
> 
> Quoting Mathias Gibbens (mathias at calenhad.com):
> >   This patch also seems to fix a segfault I encountered today after
> > upgrading to lxcfs-0.15. My host is Debian jessie 64bit running
> > unprivileged jessie containers with systemd as their init. lxcfs-0.13
> > works, lxcfs-0.15 segfaults, and lxcfs-git at 1204f57 works again.
> > 
> >   In the short time since lxcfs-0.15 is out, can anyone else confirm
> > this?
> > 
> > Mathias
> > 
> > On Fri, 2016-01-08 at 20:10 +0000, Serge Hallyn wrote:
> > > > From 24e98d74ca279ed2dc8e5a025add5a00737ba952 Mon Sep 17 00:00:00
> > > 2001
> > > > From: Wolfgang Bumiller <w.bumiller at proxmox.com>
> > > > Date: Fri, 8 Jan 2016 11:09:57 +0100
> > > > Subject: [PATCH lxcfs] cgfs: make dorealloc allocate the first
> > > batch, too
> > > > 
> > > > With a short first line the case can be
> > > >  *mem = NULL
> > > >  oldlen = 0
> > > >  newlen = 5 (anything < 50)
> > > > making newbatches == oldbatches == 1 causing the
> > > >  (newbatches <= oldbatches)
> > > > condition to be true.
> > > > 
> > > > Let realloc() handle *mem==NULL and use
> > > > (!*mem || newbatches > oldbatches) as the only condition.
> > > > 
> > > > Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
> > > 
> > > Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>
> > > 
> > > Looks good to me, thanks.
> > > 
> > > > ---
> > > >  cgfs.c  | 9 +--------
> > > >  lxcfs.c | 2 +-
> > > >  2 files changed, 2 insertions(+), 9 deletions(-)
> > > > 
> > > > diff --git a/cgfs.c b/cgfs.c
> > > > index 1f31ed1..e6330e3 100644
> > > > --- a/cgfs.c
> > > > +++ b/cgfs.c
> > > > @@ -77,14 +77,7 @@ static void dorealloc(char **mem, size_t oldlen,
> > > size_t
> > > > newlen)
> > > >       int newbatches = (newlen / BATCH_SIZE) + 1;
> > > >       int oldbatches = (oldlen / BATCH_SIZE) + 1;
> > > >  
> > > > -     if (newbatches <= oldbatches)
> > > > -             return;
> > > > -
> > > > -     if (!*mem) {
> > > > -             do {
> > > > -                     *mem = malloc(newbatches * BATCH_SIZE);
> > > > -             } while (!*mem);
> > > > -     } else {
> > > > +     if (!*mem || newbatches > oldbatches) {
> > > >               char *tmp;
> > > >               do {
> > > >                       tmp = realloc(*mem, newbatches * BATCH_SIZE);
> > > > -- 
> > > > 2.1.4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160108/603143e6/attachment.sig>


More information about the lxc-devel mailing list