From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:44924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrUBP-0007Lz-On for qemu-devel@nongnu.org; Thu, 11 Aug 2011 08:16:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QrUBL-0004tl-2f for qemu-devel@nongnu.org; Thu, 11 Aug 2011 08:16:19 -0400 Received: from mail-wy0-f173.google.com ([74.125.82.173]:37686) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrUBK-0004th-Ub for qemu-devel@nongnu.org; Thu, 11 Aug 2011 08:16:15 -0400 Received: by wyf22 with SMTP id 22so1535465wyf.4 for ; Thu, 11 Aug 2011 05:16:14 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4E43C80B.1050300@redhat.com> Date: Thu, 11 Aug 2011 14:16:11 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <4E0CA885.2050308@siemens.com> <4E0ECDDB.9030001@web.de> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] tcg: Reload local variables after return from longjmp List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Blue Swirl , TeLeMan , Jan Kiszka , qemu-devel , David Gilbert On 08/11/2011 01:30 PM, Peter Maydell wrote: >> > 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. > Can you give more details of what compiler/platform this was > a problem for? My reading of the C standard is that the compiler > isn't allowed to trash env across this longjmp, because it's > a variable of automatic scope which isn't modified between the > setjmp and the longjmp... longjmp can destroy any non-volatile variable (-Wclobbered warns about this). Paolo