diff mbox series

tests: fix a memory in test_socket_unix_abstract_good

Message ID 20200603161409.54682-1-liq3ea@163.com (mailing list archive)
State New, archived
Headers show
Series tests: fix a memory in test_socket_unix_abstract_good | expand

Commit Message

Li Qiang June 3, 2020, 4:14 p.m. UTC
After build qemu with '-fsanitize=address' extra-cflags,
'make check' show following leak:

=================================================================
==44580==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 2500 byte(s) in 1 object(s) allocated from:
    #0 0x7f1b5a8b8d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x7f1b5a514b10 in g_malloc0 (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x51b10)
    #2 0xd79ea4e4c0ad31c3  (<unknown module>)

SUMMARY: AddressSanitizer: 2500 byte(s) leaked in 1 allocation(s).

Call 'g_rand_free' in the end of function to avoid this.

Fixes: 4d3a329af59("tests/util-sockets: add abstract unix socket cases")
Signed-off-by: Li Qiang <liq3ea@163.com>
---
 tests/test-util-sockets.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Philippe Mathieu-Daudé June 3, 2020, 5:25 p.m. UTC | #1
On 6/3/20 6:14 PM, Li Qiang wrote:
> After build qemu with '-fsanitize=address' extra-cflags,
> 'make check' show following leak:
> 
> =================================================================
> ==44580==ERROR: LeakSanitizer: detected memory leaks
> 
> Direct leak of 2500 byte(s) in 1 object(s) allocated from:
>     #0 0x7f1b5a8b8d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
>     #1 0x7f1b5a514b10 in g_malloc0 (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x51b10)
>     #2 0xd79ea4e4c0ad31c3  (<unknown module>)
> 
> SUMMARY: AddressSanitizer: 2500 byte(s) leaked in 1 allocation(s).
> 
> Call 'g_rand_free' in the end of function to avoid this.

GLib doc doesn't seem complete (they don't mention explicitly the
generator returned from g_rand_new has to be released with g_rand_free).

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> 
> Fixes: 4d3a329af59("tests/util-sockets: add abstract unix socket cases")
> Signed-off-by: Li Qiang <liq3ea@163.com>
> ---
>  tests/test-util-sockets.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tests/test-util-sockets.c b/tests/test-util-sockets.c
> index 2ca1e99f17..ca6671f9bf 100644
> --- a/tests/test-util-sockets.c
> +++ b/tests/test-util-sockets.c
> @@ -312,6 +312,7 @@ static void test_socket_unix_abstract_good(void)
>      g_thread_join(serv);
>  
>      g_free(abstract_sock_name);
> +    g_rand_free(r);
>  }
>  #endif
>  
>
zhao xiao qiang June 3, 2020, 11:10 p.m. UTC | #2
在 2020/6/4 上午12:14, Li Qiang 写道:
> After build qemu with '-fsanitize=address' extra-cflags,
> 'make check' show following leak:
>
> =================================================================
> ==44580==ERROR: LeakSanitizer: detected memory leaks
>
> Direct leak of 2500 byte(s) in 1 object(s) allocated from:
>      #0 0x7f1b5a8b8d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
>      #1 0x7f1b5a514b10 in g_malloc0 (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x51b10)
>      #2 0xd79ea4e4c0ad31c3  (<unknown module>)
>
> SUMMARY: AddressSanitizer: 2500 byte(s) leaked in 1 allocation(s).
>
> Call 'g_rand_free' in the end of function to avoid this.
>
> Fixes: 4d3a329af59("tests/util-sockets: add abstract unix socket cases")
> Signed-off-by: Li Qiang <liq3ea@163.com>
> ---
>   tests/test-util-sockets.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/tests/test-util-sockets.c b/tests/test-util-sockets.c
> index 2ca1e99f17..ca6671f9bf 100644
> --- a/tests/test-util-sockets.c
> +++ b/tests/test-util-sockets.c
> @@ -312,6 +312,7 @@ static void test_socket_unix_abstract_good(void)
>       g_thread_join(serv);
>   
>       g_free(abstract_sock_name);
> +    g_rand_free(r);
>   }
>   #endif
>   

Reviewed-by:  xiaoqiang zhao <zxq_yx_007@163.com>
Li Qiang June 18, 2020, 6:12 a.m. UTC | #3
Ping..
Anyone queued this?

Thanks,
Li Qiang

Li Qiang <liq3ea@163.com> 于2020年6月4日周四 上午12:31写道:

> After build qemu with '-fsanitize=address' extra-cflags,
> 'make check' show following leak:
>
> =================================================================
> ==44580==ERROR: LeakSanitizer: detected memory leaks
>
> Direct leak of 2500 byte(s) in 1 object(s) allocated from:
>     #0 0x7f1b5a8b8d28 in __interceptor_calloc
> (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
>     #1 0x7f1b5a514b10 in g_malloc0
> (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x51b10)
>     #2 0xd79ea4e4c0ad31c3  (<unknown module>)
>
> SUMMARY: AddressSanitizer: 2500 byte(s) leaked in 1 allocation(s).
>
> Call 'g_rand_free' in the end of function to avoid this.
>
> Fixes: 4d3a329af59("tests/util-sockets: add abstract unix socket cases")
> Signed-off-by: Li Qiang <liq3ea@163.com>
> ---
>  tests/test-util-sockets.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/tests/test-util-sockets.c b/tests/test-util-sockets.c
> index 2ca1e99f17..ca6671f9bf 100644
> --- a/tests/test-util-sockets.c
> +++ b/tests/test-util-sockets.c
> @@ -312,6 +312,7 @@ static void test_socket_unix_abstract_good(void)
>      g_thread_join(serv);
>
>      g_free(abstract_sock_name);
> +    g_rand_free(r);
>  }
>  #endif
>
> --
> 2.17.1
>
>
>
Daniel P. Berrangé June 24, 2020, 10:56 a.m. UTC | #4
On Thu, Jun 18, 2020 at 02:12:58PM +0800, Li Qiang wrote:
> Ping..
> Anyone queued this?

Thanks, I've queud this now.

> 
> Thanks,
> Li Qiang
> 
> Li Qiang <liq3ea@163.com> 于2020年6月4日周四 上午12:31写道:
> 
> > After build qemu with '-fsanitize=address' extra-cflags,
> > 'make check' show following leak:
> >
> > =================================================================
> > ==44580==ERROR: LeakSanitizer: detected memory leaks
> >
> > Direct leak of 2500 byte(s) in 1 object(s) allocated from:
> >     #0 0x7f1b5a8b8d28 in __interceptor_calloc
> > (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
> >     #1 0x7f1b5a514b10 in g_malloc0
> > (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x51b10)
> >     #2 0xd79ea4e4c0ad31c3  (<unknown module>)
> >
> > SUMMARY: AddressSanitizer: 2500 byte(s) leaked in 1 allocation(s).
> >
> > Call 'g_rand_free' in the end of function to avoid this.
> >
> > Fixes: 4d3a329af59("tests/util-sockets: add abstract unix socket cases")
> > Signed-off-by: Li Qiang <liq3ea@163.com>
> > ---
> >  tests/test-util-sockets.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/tests/test-util-sockets.c b/tests/test-util-sockets.c
> > index 2ca1e99f17..ca6671f9bf 100644
> > --- a/tests/test-util-sockets.c
> > +++ b/tests/test-util-sockets.c
> > @@ -312,6 +312,7 @@ static void test_socket_unix_abstract_good(void)
> >      g_thread_join(serv);
> >
> >      g_free(abstract_sock_name);
> > +    g_rand_free(r);
> >  }
> >  #endif
> >
> > --
> > 2.17.1
> >
> >
> >

Regards,
Daniel
Li Qiang Aug. 13, 2020, 4:32 p.m. UTC | #5
Daniel P. Berrangé <berrange@redhat.com> 于2020年6月24日周三 下午6:56写道:
>
> On Thu, Jun 18, 2020 at 02:12:58PM +0800, Li Qiang wrote:
> > Ping..
> > Anyone queued this?
>
> Thanks, I've queud this now.

Hi Daniel,
It seems this patch still not in the upstream.

Thanks,
Li Qiang

>
> >
> > Thanks,
> > Li Qiang
> >
> > Li Qiang <liq3ea@163.com> 于2020年6月4日周四 上午12:31写道:
> >
> > > After build qemu with '-fsanitize=address' extra-cflags,
> > > 'make check' show following leak:
> > >
> > > =================================================================
> > > ==44580==ERROR: LeakSanitizer: detected memory leaks
> > >
> > > Direct leak of 2500 byte(s) in 1 object(s) allocated from:
> > >     #0 0x7f1b5a8b8d28 in __interceptor_calloc
> > > (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
> > >     #1 0x7f1b5a514b10 in g_malloc0
> > > (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x51b10)
> > >     #2 0xd79ea4e4c0ad31c3  (<unknown module>)
> > >
> > > SUMMARY: AddressSanitizer: 2500 byte(s) leaked in 1 allocation(s).
> > >
> > > Call 'g_rand_free' in the end of function to avoid this.
> > >
> > > Fixes: 4d3a329af59("tests/util-sockets: add abstract unix socket cases")
> > > Signed-off-by: Li Qiang <liq3ea@163.com>
> > > ---
> > >  tests/test-util-sockets.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/tests/test-util-sockets.c b/tests/test-util-sockets.c
> > > index 2ca1e99f17..ca6671f9bf 100644
> > > --- a/tests/test-util-sockets.c
> > > +++ b/tests/test-util-sockets.c
> > > @@ -312,6 +312,7 @@ static void test_socket_unix_abstract_good(void)
> > >      g_thread_join(serv);
> > >
> > >      g_free(abstract_sock_name);
> > > +    g_rand_free(r);
> > >  }
> > >  #endif
> > >
> > > --
> > > 2.17.1
> > >
> > >
> > >
>
> Regards,
> Daniel
> --
> |: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org         -o-            https://fstop138.berrange.com :|
> |: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
>
Markus Armbruster Aug. 25, 2020, 5:59 a.m. UTC | #6
Li Qiang <liq3ea@gmail.com> writes:

> Hi Daniel,
> It seems this patch still not in the upstream.

Cc: qemu-trivial, hope this helps.
diff mbox series

Patch

diff --git a/tests/test-util-sockets.c b/tests/test-util-sockets.c
index 2ca1e99f17..ca6671f9bf 100644
--- a/tests/test-util-sockets.c
+++ b/tests/test-util-sockets.c
@@ -312,6 +312,7 @@  static void test_socket_unix_abstract_good(void)
     g_thread_join(serv);
 
     g_free(abstract_sock_name);
+    g_rand_free(r);
 }
 #endif