qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC] [PATCHv8 13/30] aio / timers: Add aio_timer_new w


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [RFC] [PATCHv8 13/30] aio / timers: Add aio_timer_new wrapper
Date: Sat, 10 Aug 2013 10:36:00 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7

Il 10/08/2013 00:57, Alex Bligh ha scritto:
> There are a large number of users of qemu_free_timer (now timer_free).
> 
> If someone does not call qemu_free_timer having called qemu_new_timer,
> the timer sits there and basically does nothing.

If you have called qemu_del_timer, it is a memory leak.  If you haven't,
you'll get almost the same crash you describe here:

> If we go to the timer_init model, the timer will either be on the
> stack or (more likely) inside some other struct on the heap, which
> will likely have been freed. This means walking the timer list will
> be dangerous.

With heap-allocated timers, the timer will exist on the heap, but likely
the opaque will not and you'll get a crash in the callback.

> This seems to add a good deal of fragility.

It is really the same.  The disadvantage is that you will not have a
hint of which timer was accessed erroneously (the callback is a useful
hint).  The advantage is that you cannot leak timers, and the crash
happens deterministically as soon as the object is deleted (rather than
only when the timer fires).

Paolo



reply via email to

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