Skip to contentSkip to conversation

tests: fix a memory in test_socket_unix_abstract_good

PATCH In review Li Qiang 6 participants 7 messages Jun 3, 2020 – Aug 25, 2020

lore
Share & tools
lore

Li Qiang

author
#0 lore raw

PATCH 1/1 tests: fix a memory in test_socket_unix_abstract_good

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")
---
 tests/test-util-sockets.c | 1 +
 1 file changed, 1 insertion(+)
tests/test-util-sockets.c +1 -0
index 2ca1e99f17..ca6671f9bf 100644
@@ -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
 
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Li Qiang

After build qemu with '-fsanitize=address' extra-cflags, 'make check' show following leak:

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

Quoted 8 lines

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).

Quoted 20 lines
Fixes 4d3a329af59("tests/util-sockets: add abstract unix socket cases")
---
 tests/test-util-sockets.c | 1 +
 1 file changed, 1 insertion(+)
tests/test-util-sockets.c +1 -0
index 2ca1e99f17..ca6671f9bf 100644
@@ -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 on v1 1/1
#2 lore raw
In reply to Li Qiang
Quoted 26 lines · 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")
---
  tests/test-util-sockets.c | 1 +
  1 file changed, 1 insertion(+)
tests/test-util-sockets.c +0 -0
index 2ca1e99f17..ca6671f9bf 100644

tests/test-util-sockets.c static void test_socket_unix_abstract_good(void) · line 318

Quoted 7 lines
tests/test-util-sockets.c +1 -0
@@ -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
 
#3 lore raw
In reply to Li Qiang

Ping..
Anyone queued this?

Thanks,
Li Qiang

Quoted 40 lines · Li Qiang <[email protected]> 于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")
---
 tests/test-util-sockets.c | 1 +
 1 file changed, 1 insertion(+)
tests/test-util-sockets.c +1 -1
index 2ca1e99f17..ca6671f9bf 100644
@@ -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

#4 lore raw
Quoted 2 lines · Li Qiang

Ping..
Anyone queued this?

Thanks, I've queud this now.

Quoted 41 lines

Thanks,
Li Qiang

Quoted 35 lines · Li Qiang <[email protected]> 于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")
---
 tests/test-util-sockets.c | 1 +
 1 file changed, 1 insertion(+)
tests/test-util-sockets.c +1 -0
index 2ca1e99f17..ca6671f9bf 100644
@@ -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
 
Quoted 5 lines
Quoted 5 lines

--
2.17.1

Regards,
Daniel

Signature · 3 lines
|: 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 :|
#5 lore raw
Quoted 6 lines · Daniel P. Berrangé <[email protected]> 于2020年6月24日周三 下午6:56写道:
Quoted 2 lines · Li Qiang

Ping..
Anyone queued this?

Thanks, I've queud this now.

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

Thanks,
Li Qiang

Quoted 55 lines
Quoted 42 lines

Thanks,
Li Qiang

Quoted 35 lines · Li Qiang <[email protected]> 于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")
---
 tests/test-util-sockets.c | 1 +
 1 file changed, 1 insertion(+)
tests/test-util-sockets.c +1 -0
index 2ca1e99f17..ca6671f9bf 100644
@@ -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
 
Quoted 5 lines
Quoted 5 lines

--
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 :|
#6 lore raw
Quoted 2 lines · Li Qiang

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

Cc qemu-trivial, hope this helps.