Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M5jNy-0006nh-6Q for qemu-devel@nongnu.org; Sun, 17 May 2009 12:38:50 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M5jNt-0006lT-Mi for qemu-devel@nongnu.org; Sun, 17 May 2009 12:38:49 -0400 Received: from [199.232.76.173] (port=34702 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M5jNt-0006lI-GJ for qemu-devel@nongnu.org; Sun, 17 May 2009 12:38:45 -0400 Received: from smtp5-g21.free.fr ([212.27.42.5]:44996) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M5jNs-0001en-G3 for qemu-devel@nongnu.org; Sun, 17 May 2009 12:38:45 -0400 Received: from smtp5-g21.free.fr (localhost [127.0.0.1]) by smtp5-g21.free.fr (Postfix) with ESMTP id 84ECDD48082 for ; Sun, 17 May 2009 18:38:39 +0200 (CEST) Received: from jcd-laptop.localnet (lns-bzn-31-82-252-199-121.adsl.proxad.net [82.252.199.121]) by smtp5-g21.free.fr (Postfix) with ESMTP id 98E35D480F3 for ; Sun, 17 May 2009 18:38:37 +0200 (CEST) From: "Jean-Christophe Dubois" Date: Sun, 17 May 2009 18:38:39 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200905171838.40006.jcd@tribudubois.net> Subject: [Qemu-devel] [PATCH] Fix NULL alarm_timer pointer at exit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This fixes a SIGSEGV error on qemu exit. Here is the valgrind output related to this error ==3648== Process terminating with default action of signal 11 (SIGSEGV) ==3648== Access not within mapped region at address 0x8 ==3648== at 0x40636B: host_alarm_handler (vl.c:1345) ==3648== by 0x52D807F: (within /lib/libpthread-2.9.so) ==3648== by 0x5C0A12E: tcsetattr (in /lib/libc-2.9.so) ==3648== by 0x4DD601: term_exit (qemu-char.c:700) ==3648== by 0x5B636EC: exit (in /lib/libc-2.9.so) ==3648== by 0x5B4B5AC: (below main) (in /lib/libc-2.9.so) This simple fix check for a valid pointer as host_alarm_handler is also called after alarm_timer is released in the exit path. Signed-off-by: Jean-Christophe DUBOIS --- qemu.org/vl.c 2009-05-16 17:57:27.000000000 +0200 +++ qemu/vl.c 2009-05-17 17:15:29.000000000 +0200 @@ -915,7 +915,7 @@ static inline int alarm_has_dynticks(struct qemu_alarm_timer *t) { - return t->flags & ALARM_FLAG_DYNTICKS; + return t && (t->flags & ALARM_FLAG_DYNTICKS); } static void qemu_rearm_alarm_timer(struct qemu_alarm_timer *t) @@ -1349,7 +1349,7 @@ qemu_timer_expired(active_timers[QEMU_TIMER_REALTIME], qemu_get_clock(rt_clock))) { qemu_event_increment(); - alarm_timer->flags |= ALARM_FLAG_EXPIRED; + if (alarm_timer) alarm_timer->flags |= ALARM_FLAG_EXPIRED; #ifndef CONFIG_IOTHREAD if (next_cpu) {