* Should I delete created coroutines manually?
@ 2020-08-17 13:13 Coiby Xu
2020-08-18 15:19 ` Stefan Hajnoczi
0 siblings, 1 reply; 3+ messages in thread
From: Coiby Xu @ 2020-08-17 13:13 UTC (permalink / raw)
To: qemu-devel; +Cc: stefanha
Hi,
I'm working on vhost-user block device backend [1]. When I tested my
patches on the latest version of QEMU (commit
d0ed6a69d399ae193959225cdeaa9382746c91cc) with --enable-sanitizer turned
on, the follow error will be thrown out,
==46631==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 312 byte(s) in 1 object(s) allocated from:
#0 0x55d0a7813921 in calloc (qemu/qemu-storage-daemon+0x646921)
#1 0x7f8bd6f7b591 in g_malloc0 (/usr/lib/libglib-2.0.so.0+0x4f591)
#2 0x55d0a815f3fb in qemu_coroutine_create qemu/util/qemu-coroutine.c:75:14
#3 0x55d0a817321e in vu_client_start qemu/util/vhost-user-server.c:225:23
#4 0x55d0a816fcf3 in vu_accept qemu/util/vhost-user-server.c:341:5
#5 0x55d0a7f1293f in qio_net_listener_channel_func qemu/io/net-listener.c:54:9
#6 0x55d0a7efb0f3 in qio_channel_fd_source_dispatch qemu/io/channel-watch.c:84:12
#7 0x7f8bd6f7e33f in g_main_context_dispatch (/usr/lib/libglib-2.0.so.0+0x5233f)
I have to call qemu_coroutine_delete to eliminate this kind of errors.
I noticed
make docker-test-clang@ubuntu SHOW_ENV=1 J=12 TARGET_LIST=x86_64-softmmu EXTRA_CONFIGURE_OPTS=--enable-sanitizers"
won't give the above error while
"make docker-test-debug@fedora TARGET_LIST=x86_64-softmmu J=12" would.
And for older commits like commit eea8f5df4ecc607d64f091b8d916fcc11a697541,
this kind of error won't be shown either.
Is this kind of error true a false positve because "ASan doesn't fully
support makecontext/swapcontext functions and may produce false positives in some cases"?
I don't have sufficient knowledge on QEMU coroutine and ASan to reach a
conclusion. Could anyone enlighten me? Thank you!
[1] https://patchew.org/QEMU/20200614183907.514282-1-coiby.xu@gmail.com/
--
Best regards,
Coiby
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Should I delete created coroutines manually?
2020-08-17 13:13 Should I delete created coroutines manually? Coiby Xu
@ 2020-08-18 15:19 ` Stefan Hajnoczi
2020-09-18 5:00 ` Coiby Xu
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Hajnoczi @ 2020-08-18 15:19 UTC (permalink / raw)
To: Coiby Xu; +Cc: Kevin Wolf, qemu-devel
On Mon, Aug 17, 2020 at 2:13 PM Coiby Xu <coiby.xu@gmail.com> wrote:
> I'm working on vhost-user block device backend [1]. When I tested my
> patches on the latest version of QEMU (commit
> d0ed6a69d399ae193959225cdeaa9382746c91cc) with --enable-sanitizer turned
> on, the follow error will be thrown out,
>
> ==46631==ERROR: LeakSanitizer: detected memory leaks
>
> Direct leak of 312 byte(s) in 1 object(s) allocated from:
> #0 0x55d0a7813921 in calloc (qemu/qemu-storage-daemon+0x646921)
> #1 0x7f8bd6f7b591 in g_malloc0 (/usr/lib/libglib-2.0.so.0+0x4f591)
> #2 0x55d0a815f3fb in qemu_coroutine_create qemu/util/qemu-coroutine.c:75:14
> #3 0x55d0a817321e in vu_client_start qemu/util/vhost-user-server.c:225:23
> #4 0x55d0a816fcf3 in vu_accept qemu/util/vhost-user-server.c:341:5
> #5 0x55d0a7f1293f in qio_net_listener_channel_func qemu/io/net-listener.c:54:9
> #6 0x55d0a7efb0f3 in qio_channel_fd_source_dispatch qemu/io/channel-watch.c:84:12
> #7 0x7f8bd6f7e33f in g_main_context_dispatch (/usr/lib/libglib-2.0.so.0+0x5233f)
>
> I have to call qemu_coroutine_delete to eliminate this kind of errors.
qemu_coroutine_delete() is an internal API and shouldn't be called directly.
If you are sure that the coroutine terminated (returned from its entry
function) then the leak is probably caused by the following:
util/qemu-coroutine.c has a pool of Coroutine objects that are reused.
It's likely that the "leaked" object is in that pool.
I'm surprised that this issue hasn't been reported before, but
release_pool should be cleaned up when the program terminates.
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Should I delete created coroutines manually?
2020-08-18 15:19 ` Stefan Hajnoczi
@ 2020-09-18 5:00 ` Coiby Xu
0 siblings, 0 replies; 3+ messages in thread
From: Coiby Xu @ 2020-09-18 5:00 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: Kevin Wolf, qemu-devel
On Tue, Aug 18, 2020 at 04:19:58PM +0100, Stefan Hajnoczi wrote:
>On Mon, Aug 17, 2020 at 2:13 PM Coiby Xu <coiby.xu@gmail.com> wrote:
>> I'm working on vhost-user block device backend [1]. When I tested my
>> patches on the latest version of QEMU (commit
>> d0ed6a69d399ae193959225cdeaa9382746c91cc) with --enable-sanitizer turned
>> on, the follow error will be thrown out,
>>
>> ==46631==ERROR: LeakSanitizer: detected memory leaks
>>
>> Direct leak of 312 byte(s) in 1 object(s) allocated from:
>> #0 0x55d0a7813921 in calloc (qemu/qemu-storage-daemon+0x646921)
>> #1 0x7f8bd6f7b591 in g_malloc0 (/usr/lib/libglib-2.0.so.0+0x4f591)
>> #2 0x55d0a815f3fb in qemu_coroutine_create qemu/util/qemu-coroutine.c:75:14
>> #3 0x55d0a817321e in vu_client_start qemu/util/vhost-user-server.c:225:23
>> #4 0x55d0a816fcf3 in vu_accept qemu/util/vhost-user-server.c:341:5
>> #5 0x55d0a7f1293f in qio_net_listener_channel_func qemu/io/net-listener.c:54:9
>> #6 0x55d0a7efb0f3 in qio_channel_fd_source_dispatch qemu/io/channel-watch.c:84:12
>> #7 0x7f8bd6f7e33f in g_main_context_dispatch (/usr/lib/libglib-2.0.so.0+0x5233f)
>>
>> I have to call qemu_coroutine_delete to eliminate this kind of errors.
>
>qemu_coroutine_delete() is an internal API and shouldn't be called directly.
>
>If you are sure that the coroutine terminated (returned from its entry
>function) then the leak is probably caused by the following:
Thank you for this clue! Yesterday I realized the execution of coroutine
has been yielded since qio_channel_yield is called. Now I give the socket
server enough time to do the clean-up work after the client socket is
closed and the issue is gone.
>
>util/qemu-coroutine.c has a pool of Coroutine objects that are reused.
>It's likely that the "leaked" object is in that pool.
>
>I'm surprised that this issue hasn't been reported before, but
>release_pool should be cleaned up when the program terminates.
I still can't figure out why the issue hasn't been reported before. I guess
I have to put it aside.
>
>Stefan
--
Best regards,
Coiby
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-18 5:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-17 13:13 Should I delete created coroutines manually? Coiby Xu
2020-08-18 15:19 ` Stefan Hajnoczi
2020-09-18 5:00 ` Coiby Xu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.