qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] cpus: fix TCG timer leak


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH] cpus: fix TCG timer leak
Date: Wed, 26 Sep 2018 09:52:12 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

On 25/09/2018 22:17, Alex Bennée wrote:
> 
> Marc-André Lureau <address@hidden> writes:
> 
>> Spotted by ASAN:
>>
>> QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 tests/bios-tables-test  
>> -p /x86_64/acpi/piix4/cpuhp
>> /x86_64/acpi/piix4/cpuhp: Could not access KVM kernel module: No such file 
>> or directory
>> qemu-system-x86_64: failed to initialize KVM: No such file or directory
>> qemu-system-x86_64: Back to tcg accelerator
>> ==21216==WARNING: ASan doesn't fully support makecontext/swapcontext 
>> functions and may produce false positives in some cases!
>>
>> =================================================================
>> ==21216==ERROR: LeakSanitizer: detected memory leaks
>>
>> Direct leak of 48 byte(s) in 1 object(s) allocated from:
>>     #0 0x7f77c0668e50 in calloc (/lib64/libasan.so.5+0xeee50)
>>     #1 0x7f77beb7b41d in g_malloc0 (/lib64/libglib-2.0.so.0+0x5241d)
>>     #2 0x557f756df5bd in timer_new 
>> /home/elmarco/src/qemu/include/qemu/timer.h:561
>>     #3 0x557f756df5ee in timer_new_ns 
>> /home/elmarco/src/qemu/include/qemu/timer.h:584
>>     #4 0x557f756e4690 in start_tcg_kick_timer 
>> /home/elmarco/src/qemu/cpus.c:965
>>     #5 0x557f756e64d7 in qemu_tcg_rr_wait_io_event 
>> /home/elmarco/src/qemu/cpus.c:1210
>>     #6 0x557f756e90ad in qemu_tcg_rr_cpu_thread_fn 
>> /home/elmarco/src/qemu/cpus.c:1536
>>     #7 0x557f76e9f233 in qemu_thread_start 
>> /home/elmarco/src/qemu/util/qemu-thread-posix.c:504
>>     #8 0x7f77b4a11593 in start_thread (/lib64/libpthread.so.0+0x7593)
>>
>> Direct leak of 48 byte(s) in 1 object(s) allocated from:
>>     #0 0x7f77c0668e50 in calloc (/lib64/libasan.so.5+0xeee50)
>>     #1 0x7f77beb7b41d in g_malloc0 (/lib64/libglib-2.0.so.0+0x5241d)
>>     #2 0x557f756df5bd in timer_new 
>> /home/elmarco/src/qemu/include/qemu/timer.h:561
>>     #3 0x557f756df5ee in timer_new_ns 
>> /home/elmarco/src/qemu/include/qemu/timer.h:584
>>     #4 0x557f756e4690 in start_tcg_kick_timer 
>> /home/elmarco/src/qemu/cpus.c:965
>>     #5 0x557f756e8616 in qemu_tcg_rr_cpu_thread_fn 
>> /home/elmarco/src/qemu/cpus.c:1466
>>     #6 0x557f76e9f233 in qemu_thread_start 
>> /home/elmarco/src/qemu/util/qemu-thread-posix.c:504
>>     #7 0x7f77b4a11593 in start_thread (/lib64/libpthread.so.0+0x7593)
>>
>> SUMMARY: AddressSanitizer: 96 byte(s) leaked in 2 allocation(s).
>>
>> Signed-off-by: Marc-André Lureau <address@hidden>
>> ---
>>  cpus.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/cpus.c b/cpus.c
>> index 719788320f..0513c657f4 100644
>> --- a/cpus.c
>> +++ b/cpus.c
>> @@ -973,6 +973,7 @@ static void stop_tcg_kick_timer(void)
>>      assert(!mttcg_enabled);
>>      if (tcg_kick_vcpu_timer) {
>>          timer_del(tcg_kick_vcpu_timer);
>> +        timer_free(tcg_kick_vcpu_timer);
>>          tcg_kick_vcpu_timer = NULL;
>>      }
>>  }
> 
> Arguably we should be stopping and starting the timer properly rather
> than re-creating it every time. However that would complicate the logic
> that is currently just using the presence of a timer reference to infer
> activeness.

You can use timer_pending for that (and then timer_init instead of
timer_new).

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]