diff --git a/cpu-exec.c b/cpu-exec.c index 5d6dd51..61b1c59 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -602,9 +602,15 @@ int cpu_exec(CPUState *env1) /* cpu_interrupt might be called while translating the TB, but before it is linked into a potentially infinite loop and becomes env->current_tb. Avoid - starting execution if there is a pending interrupt. */ - if (!unlikely (env->exit_request)) { - env->current_tb = tb; + starting execution if there is a pending interrupt. + Doing it this way is necessary to avoid races with + cpu_unlink_tb (called by cpu_exit). */ + env->current_tb = tb; + if (unlikely (env->exit_request)) { + env->current_tb = NULL; + } + + if (likely (env->current_tb)) { tc_ptr = tb->tc_ptr; /* execute the generated code */ #if defined(__sparc__) && !defined(CONFIG_SOLARIS)