From: Jan Kiszka Date: Sat, 2 Jul 2011 07:50:51 +0000 (+0200) Subject: tcg: Reload local variables after return from longjmp X-Git-Tag: TizenStudio_2.0_p2.3~2579^2~52 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=74d742f5539cd3d15c412309c60939a8f14a6d63;p=sdk%2Femulator%2Fqemu.git tcg: Reload local variables after return from longjmp 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 Signed-off-by: Blue Swirl --- 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(;;) */