From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:39250) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpGMr-0008VH-9G for qemu-devel@nongnu.org; Fri, 05 Aug 2011 05:06:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QpGMq-000648-8z for qemu-devel@nongnu.org; Fri, 05 Aug 2011 05:06:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8784) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpGMp-000643-UE for qemu-devel@nongnu.org; Fri, 05 Aug 2011 05:06:56 -0400 Message-ID: <4E3BB35A.6070006@redhat.com> Date: Fri, 05 Aug 2011 11:09:46 +0200 From: Kevin Wolf MIME-Version: 1.0 References: <4E3B9BE4.3020807@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] Build broken List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org, Stefan Hajnoczi Am 05.08.2011 10:48, schrieb Stefan Hajnoczi: > On Fri, Aug 5, 2011 at 8:29 AM, Kevin Wolf wrote: >> Am 05.08.2011 08:22, schrieb malc: >>> >>> /home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c: In function 'coroutine_new': >>> /home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c:160:16: error: 'arg.i[1]' may be used uninitialized in this function >>> /home/malc/x/rcs/git/qemuorg/coroutine-ucontext.c:136:18: note: 'arg.i[1]' was declared here >>> >>> diff --git a/coroutine-ucontext.c b/coroutine-ucontext.c >>> index 41c2379..42dc3e2 100644 >>> --- a/coroutine-ucontext.c >>> +++ b/coroutine-ucontext.c >>> @@ -133,7 +133,7 @@ static Coroutine *coroutine_new(void) >>> CoroutineUContext *co; >>> ucontext_t old_uc, uc; >>> jmp_buf old_env; >>> - union cc_arg arg; >>> + union cc_arg arg = {0}; >>> >>> /* The ucontext functions preserve signal masks which incurs a system call >>> * overhead. setjmp()/longjmp() does not preserve signal masks but only >>> >>> I guess gcc should yell not only here on ppc32 but on any machine where >>> pointer size is less than the size of two ints. >> >> Stefan, why does this code even exist again? I think at some point I had >> it changed to just use a static variable in order to avoid doing this >> kind of tricks with unions. > > virtfs are using coroutines in multiple threads at the same time. > Introducing a global variable wouldn't be thread-safe. > > The real problem is that makecontext(3) has a bad function signature. > There's no nice fix - whatever we do will be ugly. > > Using a union is the way it should be done in C. The code doesn't > look pretty but it doesn't introduce global state. But it makes assumptions about the pointer size, which isn't a nice thing. TLS isn't an option for compatibility with some OSes/architectures? Kevin