]> git.proxmox.com Git - qemu.git/commitdiff
tcg: Reload local variables after return from longjmp
authorJan Kiszka <jan.kiszka@siemens.com>
Sat, 2 Jul 2011 07:50:51 +0000 (09:50 +0200)
committerBlue Swirl <blauwirbel@gmail.com>
Tue, 12 Jul 2011 20:53:28 +0000 (20:53 +0000)
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>
cpu-exec.c

index 20e3ec41d76be53d7f9e290b674f908d9baf4aa0..de0d716da0615a7293b69a949133255848c78414 100644 (file)
@@ -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(;;) */