qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: Thomas Huth <thuth@redhat.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Eric Blake <eblake@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Richard Henderson <richard.henderson@linaro.org>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: Memory leak in bitmap code?
Date: Mon, 20 Jul 2020 10:50:23 +0300	[thread overview]
Message-ID: <90825871-7259-d516-e103-176d0433c4e6@virtuozzo.com> (raw)
In-Reply-To: <16102b4a-160a-a400-a332-4477b83468d8@redhat.com>

20.07.2020 09:16, Thomas Huth wrote:
> 
>   Hi,
> 
> looks like the LeakSanitizer spotted a memory leak in the bitmap related
> code ... not sure why it just triggered with Richard's pull request, and
> I can also not reproduce it... But since there is a nice backtrace in it
> and there have been some bitmap-related patches recently, could you
> maybe have a look whether this rings a bell by any chance:
> 
>   https://gitlab.com/qemu-project/qemu/-/jobs/645799805#L3282
> 

Hi! Hmm. bitmap.c/bitmap.h is a simple bitmap library, which was not changed this
year. The last commit I see is about a year ago.

So, I assume the problem should be somewhere below in the stack trace.

I don't know this code, but try to look at:

OK, sanitizer reports that we loose the memory allocated at exce.c:2219, i.e.

new_blocks->blocks1[j] = bitmap_new(DIRTY_MEMORY_BLOCK_SIZE);

Hmm. And where is this bitmap released? I can't find the place. May be the leak
was introduced in far 5b82b703b69acc67b7 with this bitmap_new()? Add Stefan to
CC.

> 
>   Thanks,
>    Thomas
> 
> 
> On 19/07/2020 21.35, GitLab via wrote:
>> GitLab
>> ✖ 	Your pipeline has failed.
>>
>>   
>> Project 	QEMU <https://gitlab.com/qemu-project> / QEMU
>> <https://gitlab.com/qemu-project/qemu>
>> Branch 	
>> 	master <https://gitlab.com/qemu-project/qemu/-/commits/master>
>>
>> Commit 	
>> 	9fc87111
>> <https://gitlab.com/qemu-project/qemu/-/commit/9fc87111005e8903785db40819af66b8f85b8b96>
>>
>>
>> Merge remote-tracking branch 'remotes/rth/tags/...
>> Commit Author 	
>> 	Peter Maydell <https://gitlab.com/pm215>
>>
>>   
>> Pipeline #168317253
>> <https://gitlab.com/qemu-project/qemu/-/pipelines/168317253>
>> triggered by 		Alex Bennée <https://gitlab.com/stsquad>
>>
>> had 1 failed build.
>> Logs may contain sensitive data. Please consider before forwarding this
>> email.
>> ✖ 	build
>>
>> 	build-fuzzer <https://gitlab.com/qemu-project/qemu/-/jobs/645799805>
>>
>> ==11111==ERROR: LeakSanitizer: detected memory leaks
>>
>> Direct leak of 2359296 byte(s) in 9 object(s) allocated from:
>> #0 0x5570060105d7 in calloc
>> (/builds/qemu-project/qemu/build/x86_64-softmmu/qemu-system-x86_64+0x2bdb5d7)
>> #1 0x55700605ddf9 in bitmap_try_new
>> /builds/qemu-project/qemu/include/qemu/bitmap.h:96:12
>> #2 0x55700605ddf9 in bitmap_new
>> /builds/qemu-project/qemu/include/qemu/bitmap.h:101:26
>> #3 0x55700605ddf9 in dirty_memory_extend
>> /builds/qemu-project/qemu/exec.c:2219:37
>> #4 0x55700605ddf9 in ram_block_add /builds/qemu-project/qemu/exec.c:2268:9
>> #5 0x5570060611b4 in qemu_ram_alloc_internal
>> /builds/qemu-project/qemu/exec.c:2441:5
>> #6 0x557006061567 in qemu_ram_alloc /builds/qemu-project/qemu/exec.c:2460:12
>> #7 0x55700675d350 in memory_region_init_ram_shared_nomigrate
>> /builds/qemu-project/qemu/softmmu/memory.c:1514:21
>> #8 0x557006bdd127 in ram_backend_memory_alloc
>> /builds/qemu-project/qemu/backends/hostmem-ram.c:30:5
>> #9 0x557006bd9733 in host_memory_backend_memory_complete
>> /builds/qemu-project/qemu/backends/hostmem.c:333:9
>> #10 0x557007a20ffc in user_creatable_complete
>> /builds/qemu-project/qemu/qom/object_interfaces.c:23:9
>> #11 0x557007a2178a in user_creatable_add_type
>> /builds/qemu-project/qemu/qom/object_interfaces.c:93:10
>> #12 0x557007a219dc in user_creatable_add_dict
>> /builds/qemu-project/qemu/qom/object_interfaces.c:134:11
>> #13 0x557007ee7eb6 in qmp_dispatch
>> /builds/qemu-project/qemu/qapi/qmp-dispatch.c:155:5
>> #14 0x5570077452a8 in monitor_qmp_dispatch
>> /builds/qemu-project/qemu/monitor/qmp.c:145:11
>> #15 0x55700774411d in monitor_qmp_bh_dispatcher
>> /builds/qemu-project/qemu/monitor/qmp.c:234:9
>> #16 0x557008065c66 in aio_bh_poll
>> /builds/qemu-project/qemu/util/async.c:164:13
>> #17 0x55700800235c in aio_dispatch
>> /builds/qemu-project/qemu/util/aio-posix.c:380:5
>> #18 0x55700806a62c in aio_ctx_dispatch
>> /builds/qemu-project/qemu/util/async.c:306:5
>> #19 0x7f93662807ae in g_main_context_dispatch
>> (/lib64/libglib-2.0.so.0+0x527ae)
>>
>> SUMMARY: AddressSanitizer: 2359296 byte(s) leaked in 9 allocation(s).
>> /builds/qemu-project/qemu/tests/qtest/libqtest.c:166: kill_qemu() tried
>> to terminate QEMU process but encountered exit status 1 (expected 0)
>> ERROR qmp-cmd-test - too few tests run (expected 51, got 50)
>> make: *** [/builds/qemu-project/qemu/tests/Makefile.include:650:
>> check-qtest-x86_64] Error 1
>> ERROR: Job failed: exit code 1
>>
>> GitLab
>> You're receiving this email because of your account on gitlab.com.
>> Manage all notifications <https://gitlab.com/profile/notifications> ·
>> Help <https://gitlab.com/help>
>>
> 


-- 
Best regards,
Vladimir


  reply	other threads:[~2020-07-20  8:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-19 19:35 QEMU | Pipeline #168317253 has failed for master | 9fc87111 GitLab via
2020-07-20  6:16 ` Memory leak in bitmap code? (was: QEMU | Pipeline #168317253 has failed for master | 9fc87111) Thomas Huth
2020-07-20  7:50   ` Vladimir Sementsov-Ogievskiy [this message]
2020-07-21 10:50     ` Memory leak in bitmap code? Stefan Hajnoczi
2020-07-21 12:05     ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=90825871-7259-d516-e103-176d0433c4e6@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=stefanha@redhat.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).