[lxc-devel] [PATCH] fix realloc() error on reboot container
Stéphane Graber
stgraber at ubuntu.com
Thu Feb 27 20:08:35 UTC 2014
On Thu, Feb 27, 2014 at 01:01:00PM +0400, Vitaly Lavrov wrote:
> lxc-1.0.0
>
> The container with "lxc.network.type=phys" halted with error on reboot.
>
> Error message:
> *** glibc detected *** lxc-start: realloc(): invalid pointer: 0x0948eed0 ***
>
> We have a sequence:
>
> 1) conf->saved_nic = relloc(NULL) on start start.c:container save_phys_nics()
> 2) free(conf->saved_nics) after stop container conf.c:lxc_rename_phys_nics_on_shutdown()
> 3) conf->saved_nic = relloc(conf->saved_nics) on restart container start.c:save_phys_nics() -> error relloc()
>
> free(conf->saved_nics) in lxc_rename_phys_nics_on_shutdown() unnecessary, it will be called later in lxc_clear_saved_nics().
>
> Signed-off-by: Vitaly Lavrov <vel21ripn at gmail.com>
Acked-by: Stéphane Graber <stgraber at ubuntu.com>
> --
> src/lxc/conf.c | 4 +---
> 1 file changed, 1 insertions(+), 3 deletion(-)
> diff --git a/src/lxc/conf.c b/src/lxc/conf.c
> index c9dd7ac..90d291b 100644
> --- a/src/lxc/conf.c
> +++ b/src/lxc/conf.c
> @@ -2605,7 +2605,6 @@ void lxc_rename_phys_nics_on_shutdown(struct lxc_conf *conf)
> free(s->orig_name);
> }
> conf->num_savednics = 0;
> - free(conf->saved_nics);
> }
>
> static char *default_rootfs_mount = LXCROOTFSMOUNT;
> @@ -4115,11 +4114,10 @@ static void lxc_clear_saved_nics(struct lxc_conf *conf)
> {
> int i;
>
> - if (!conf->num_savednics)
> + if (!conf->saved_nics)
> return;
> for (i=0; i < conf->num_savednics; i++)
> free(conf->saved_nics[i].orig_name);
> - conf->saved_nics = 0;
> free(conf->saved_nics);
> }
>
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140227/27da929c/attachment.pgp>
More information about the lxc-devel
mailing list