From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:47359) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qcuye-0005EX-S9 for qemu-devel@nongnu.org; Sat, 02 Jul 2011 03:50:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qcuyd-0005vJ-RY for qemu-devel@nongnu.org; Sat, 02 Jul 2011 03:50:56 -0400 Received: from fmmailgate03.web.de ([217.72.192.234]:47504) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qcuyd-0005vE-H1 for qemu-devel@nongnu.org; Sat, 02 Jul 2011 03:50:55 -0400 Message-ID: <4E0ECDDB.9030001@web.de> Date: Sat, 02 Jul 2011 09:50:51 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <4E0CA885.2050308@siemens.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: jan.kiszka@web.de Subject: [Qemu-devel] [PATCH] tcg: Reload local variables after return from longjmp List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: TeLeMan , qemu-devel From: Jan Kiszka Recent compilers look deep into cpu_exec, find longjmp as a noreturn function and decide to smash some stack variables as they won't be used again. This may lead to env becoming invalid after return from setjmp, causing crashes. Fix it by reloading env from cpu_single_env in that case. Signed-off-by: Jan Kiszka --- cpu-exec.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index 20e3ec4..de0d716 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -587,6 +587,10 @@ int cpu_exec(CPUState *env) /* reset soft MMU for next block (it can currently only be set by a memory fault) */ } /* for(;;) */ + } else { + /* Reload env after longjmp - the compiler may have smashed all + * local variables as longjmp is marked 'noreturn'. */ + env = cpu_single_env; } } /* for(;;) */