[ovs-dev] [PATCH v2 ovn] logical-fields: fix memory leak caused by initialize ovnfield_by_name twice

Damijan Skvarc damjan.skvarc at gmail.com
Tue Mar 10 15:57:52 UTC 2020


thanks for sharing your information with me. Obviously I didn't understand
you well.
thanks, damijan

On Tue, 10 Mar 2020, 16:51 Numan Siddique, <numans at ovn.org> wrote:

> On Tue, Mar 10, 2020 at 7:10 PM Damijan Skvarc <damjan.skvarc at gmail.com>
> wrote:
> >
> > On Tue, Mar 10, 2020 at 2:02 PM Numan Siddique <numans at ovn.org> wrote:
> >
> > > On Sat, Mar 7, 2020 at 4:42 AM Ben Pfaff <blp at ovn.org> wrote:
> > > >
> > > > On Thu, Mar 05, 2020 at 07:21:41AM +0100, Damijan Skvarc wrote:
> > > > > ovnfield_by_name is hash of strings which is used to quickly find
> > > > > field by name. This hash is initialized from ovn_init_symtab(). In
> case
> > > > > the latter function is called multiple times then also
> > > ovnfield_by_name is
> > > > > initialized multiple times but without freeing previously allocated
> > > > > memory resources what cause memory leaks.  This actually happens in
> > > > > ovn-controller which calls ovn_init_symtab() function twice, once
> from
> > > > > ofctrl.c and the other time from lflow.c files.
> > > >
> > > > Applied to master, thanks!
> > >
> > > Hi Ben, Damijan,
> > >
> > > I applied this patch to branch-20.03 as well for the following reasons
> > >    - This patch fixes memory leak
> > >    - branch-20.03 compilation is broken when configured with the flag
> > > '--enable-sparse'
> > >      Strangely, it used to compile for me last week. Even travis CI
> > > passed for the latest commit in branch-20.03.
> > >      I may have updated my sparse version. I'm using sparse 0.6.1 now.
> > >     Applying this patch resolves the compilation issue.
> > >
> > >     I'm seeing the below compilation error
> > >    *****
> > >    libtool: compile:  env REAL_CC=gcc "CHECK=sparse -Wsparse-error -I
> > >
> > >
> /home/nusiddiq/workspace_cpp/ovn_fdp/ovn2.13/ovn/openvswitch-2.13.0/include/sparse
> > > -m64 -I /usr/local/include  " cgcc -target=x86_64 -DHAVE_CONFIG_H -I.
> > > -I ./include -I ./include -I ./ovn -I ./include -I
> > >
> /home/nusiddiq/workspace_cpp/ovn_fdp/ovn2.13/ovn/openvswitch-2.13.0/include
> > > -I
> > >
> /home/nusiddiq/workspace_cpp/ovn_fdp/ovn2.13/ovn/openvswitch-2.13.0/include
> > > -I
> /home/nusiddiq/workspace_cpp/ovn_fdp/ovn2.13/ovn/openvswitch-2.13.0/lib
> > > -I
> /home/nusiddiq/workspace_cpp/ovn_fdp/ovn2.13/ovn/openvswitch-2.13.0/lib
> > > -I /home/nusiddiq/workspace_cpp/ovn_fdp/ovn2.13/ovn/openvswitch-2.13.0
> > > -I /home/nusiddiq/workspace_cpp/ovn_fdp/ovn2.13/ovn/openvswitch-2.13.0
> > > -I ./lib -I ./lib -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare
> > > -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum
> > > -Wunused-parameter -Wbad-function-cast -Wcast-align
> > > -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes
> > > -Wmissing-field-initializers -fno-strict-aliasing -Wswitch-bool
> > > -Wlogical-not-parentheses -Wsizeof-array-argument -Wbool-compare
> > > -Wshift-negative-value -Wduplicated-cond -Wshadow
> > > -Wmultistatement-macros -Wcast-align=strict -Werror -Werror -g -O2 -MT
> > > lib/logical-fields.lo -MD -MP -MF lib/.deps/logical-fields.Tpo -c
> > > lib/logical-fields.c -o lib/logical-fields.o
> > > lib/logical-fields.c:294:1: error: symbol 'ovn_destroy_ovnfields' was
> > > not declared. Should it be static?
> > >
> >
> > hm, according to this message it is expected the ovn_destroy_ovnfields()
> > should be static, but in fact it is static. In the
> > past it used to be non-static function. Are you sure you are not dealing
> > with some older object file artifact?
> >
>
> Sorry for the confusion. I mean we see this compilation error without
> your patch.
> Without your patch, the function ovn_destroy_ovnfields() is in fact
> non-static and
> it is declared in include/ovn/logical-fields.h. But still sparse
> complains about this.
>
> Anyway, with your patch, the compilation is resolved because you've made
> ovn_destroy_ovnfields() static.
>
> And hence I backported your patch to branch-20.03.
>
> Thanks
> Numan
>
> > make[1]: *** [Makefile:2070: lib/logical-fields.lo] Error 1
> > > make[1]: *** Waiting for unfinished jobs....
> > >    ***
> > >
> > > Thanks
> > > Numan
> > >
> > >
> > > > _______________________________________________
> > > > dev mailing list
> > > > dev at openvswitch.org
> > > > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
> > > >
> > >
> > _______________________________________________
> > dev mailing list
> > dev at openvswitch.org
> > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
> >
>


More information about the dev mailing list