Message ID | 20130807081729.GA1624@amosk.info |
---|---|
State | New |
Headers | show |
On Wed, Aug 07, 2013 at 04:17:29PM +0800, Amos Kong wrote: > BTW, can we add a check in quit_timers() to avoid one kind of crash > (try to quit the uninited timers, or quit timer repeatedly) ? > > > diff --git a/qemu-timer.c b/qemu-timer.c > index b2d95e2..023e4ae 100644 > --- a/qemu-timer.c > +++ b/qemu-timer.c > @@ -728,8 +728,10 @@ static void win32_rearm_timer(struct > qemu_alarm_timer *t, > static void quit_timers(void) > { > struct qemu_alarm_timer *t = alarm_timer; > - alarm_timer = NULL; > - t->stop(t); > + if (t) { > + alarm_timer = NULL; > + t->stop(t); > + } > } This is unnecessary once your other patch has been applied since t will be initialized before quit_timers() is installed. If we do ever hit the problem it should be debugged because assumptions about the timer lifecycle must be broken. So avoiding the segfault isn't really useful here, I think. Stefan
diff --git a/qemu-timer.c b/qemu-timer.c index b2d95e2..023e4ae 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -728,8 +728,10 @@ static void win32_rearm_timer(struct qemu_alarm_timer *t, static void quit_timers(void) { struct qemu_alarm_timer *t = alarm_timer; - alarm_timer = NULL; - t->stop(t); + if (t) { + alarm_timer = NULL; + t->stop(t); + } }