diff mbox series

[v2,13/13] tests: fix coroutine leak in /basic/entered

Message ID 20171215150659.1811-14-marcandre.lureau@redhat.com
State New
Headers show
Series Various build-sys and ASAN related fixes | expand

Commit Message

Marc-André Lureau Dec. 15, 2017, 3:06 p.m. UTC
The coroutine is not finished by the time the test ends, resulting in
ASAN warning:

==7005==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 312 byte(s) in 1 object(s) allocated from:
    #0 0x7fd35290fa38 in __interceptor_calloc (/lib64/libasan.so.4+0xdea38)
    #1 0x7fd3506c5f75 in g_malloc0 ../glib/gmem.c:124
    #2 0x55994af03e47 in qemu_coroutine_new /home/elmarco/src/qemu/util/coroutine-ucontext.c:144
    #3 0x55994aefed99 in qemu_coroutine_create /home/elmarco/src/qemu/util/qemu-coroutine.c:76
    #4 0x55994ac1eb50 in verify_entered_step_1 /home/elmarco/src/qemu/tests/test-coroutine.c:80
    #5 0x55994af03c75 in coroutine_trampoline /home/elmarco/src/qemu/util/coroutine-ucontext.c:119
    #6 0x7fd34ec02bef  (/lib64/libc.so.6+0x50bef)

Do not yield() to let the coroutine terminate.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 tests/test-coroutine.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Stefan Hajnoczi Dec. 18, 2017, 1:25 p.m. UTC | #1
On Fri, Dec 15, 2017 at 04:06:59PM +0100, Marc-André Lureau wrote:
> The coroutine is not finished by the time the test ends, resulting in
> ASAN warning:
> 
> ==7005==ERROR: LeakSanitizer: detected memory leaks
> 
> Direct leak of 312 byte(s) in 1 object(s) allocated from:
>     #0 0x7fd35290fa38 in __interceptor_calloc (/lib64/libasan.so.4+0xdea38)
>     #1 0x7fd3506c5f75 in g_malloc0 ../glib/gmem.c:124
>     #2 0x55994af03e47 in qemu_coroutine_new /home/elmarco/src/qemu/util/coroutine-ucontext.c:144
>     #3 0x55994aefed99 in qemu_coroutine_create /home/elmarco/src/qemu/util/qemu-coroutine.c:76
>     #4 0x55994ac1eb50 in verify_entered_step_1 /home/elmarco/src/qemu/tests/test-coroutine.c:80
>     #5 0x55994af03c75 in coroutine_trampoline /home/elmarco/src/qemu/util/coroutine-ucontext.c:119
>     #6 0x7fd34ec02bef  (/lib64/libc.so.6+0x50bef)
> 
> Do not yield() to let the coroutine terminate.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  tests/test-coroutine.c | 1 -
>  1 file changed, 1 deletion(-)

Looks like a copy-paste mistake, the second yield shouldn't be there.

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
diff mbox series

Patch

diff --git a/tests/test-coroutine.c b/tests/test-coroutine.c
index abd97c23c1..76c646107e 100644
--- a/tests/test-coroutine.c
+++ b/tests/test-coroutine.c
@@ -67,7 +67,6 @@  static void coroutine_fn verify_entered_step_2(void *opaque)
     /* Once more to check it still works after yielding */
     g_assert(qemu_coroutine_entered(caller));
     g_assert(qemu_coroutine_entered(qemu_coroutine_self()));
-    qemu_coroutine_yield();
 }
 
 static void coroutine_fn verify_entered_step_1(void *opaque)