summaryrefslogtreecommitdiff
path: root/cpu-exec.c
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2011-07-02 09:50:51 +0200
committerBlue Swirl <blauwirbel@gmail.com>2011-07-12 20:53:28 +0000
commit0d10193870b5a81c3bce13a602a5403c3a55cf6c (patch)
tree8e4aa763a342692fe71a115639e67ab64c33bb0d /cpu-exec.c
parent5b620fb698e69a5386f2f02c7c455bdbdd59a52b (diff)
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 <jan.kiszka@siemens.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'cpu-exec.c')
-rw-r--r--cpu-exec.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/cpu-exec.c b/cpu-exec.c
index 20e3ec41d7..de0d716da0 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(;;) */