From patchwork Fri Apr 13 14:53:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Breuer X-Patchwork-Id: 152327 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9F0DAB7011 for ; Sat, 14 Apr 2012 00:54:59 +1000 (EST) Received: from localhost ([::1]:46743 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIhtp-0000Se-KE for incoming@patchwork.ozlabs.org; Fri, 13 Apr 2012 10:54:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIhsV-0000KA-Tw for qemu-devel@nongnu.org; Fri, 13 Apr 2012 10:53:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SIhsT-0005ut-Ta for qemu-devel@nongnu.org; Fri, 13 Apr 2012 10:53:35 -0400 Received: from mail.mc.net ([209.172.128.24]:49012) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1SIhsT-0005uQ-N9 for qemu-devel@nongnu.org; Fri, 13 Apr 2012 10:53:33 -0400 Received: (qmail 29937 invoked by uid 420); 13 Apr 2012 14:53:31 -0000 Received: from unknown (HELO ?IPv6:::1?) (breuerr@209.172.177.18) by mail.mc.net with SMTP; 13 Apr 2012 14:53:31 -0000 Message-ID: <4F883DE3.2050501@mc.net> Date: Fri, 13 Apr 2012 09:53:23 -0500 From: Bob Breuer User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 MIME-Version: 1.0 To: Pavel Dovgaluk References: <002c01cd13e1$669b3730$33d1a590$@Dovgaluk@ispras.ru> <4F86AADE.2020907@redhat.com> <4F86AC08.4090203@redhat.com> <4F870362.4080605@weilnetz.de> <4F87096C.1040804@redhat.com> <003401cd1968$1c2c2240$548466c0$@Dovgaluk@ispras.ru> In-Reply-To: <003401cd1968$1c2c2240$548466c0$@Dovgaluk@ispras.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 209.172.128.24 X-Mailman-Approved-At: Fri, 13 Apr 2012 10:54:51 -0400 Cc: 'Kevin Wolf' , 'Paolo Bonzini' , 'qemu-devel' , 'Stefan Weil' Subject: Re: [Qemu-devel] Fiber switching and stack protection X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On 4/13/2012 6:25 AM, Pavel Dovgaluk wrote: >> -----Original Message----- >> From: Paolo Bonzini [mailto:pbonzini@redhat.com] >> Sent: Thursday, April 12, 2012 8:57 PM >> To: Stefan Weil >> Cc: Kevin Wolf; 'qemu-devel'; Pavel Dovgaluk >> Subject: Re: [Qemu-devel] Fiber switching and stack protection >> >> Il 12/04/2012 18:31, Stefan Weil ha scritto: >>> Am 12.04.2012 12:18, schrieb Paolo Bonzini: >>>> Il 12/04/2012 12:13, Kevin Wolf ha scritto: >>>>> I guess it's this non-thread-local TLS once again, basically a >>>>> compiler bug. > > You are right, this is a compiler bug with non-thread-local TLS. > >>>>> Paolo, wasn't there a compiler option that works around the problem? >>>>> >>>> I asked to test it (-D_MT) but never got any answer. >>> >>> I'd be surprised if defining _MT helped against compiler bugs. >> >> Well, -mthreads fixed it, and it should be the same as -D_MT -lmingwthrd. But we shouldn't >> need libmingwthrd, or do we? > > I've tried to add -mthreads to compiler options but nothing has changed, qemu still fails. This is likely a different bug than the original thread related bug. I'm using the mingw gcc 4.6.2, and I see the same thing as shown here: http://virtuallyfun.superglobalmegacorp.com/?p=1846 Something goes wrong during optimization with gcc 4.6.2, but it doesn't appear to be TLS related. Digging into it a bit, qemu_coroutine_switch() seems to break if it gets inlined. Can anyone else confirm if this one-line patch works for them? Bob diff --git a/coroutine-win32.c b/coroutine-win32.c index 4179609..504873b 100644 --- a/coroutine-win32.c +++ b/coroutine-win32.c @@ -36,6 +36,7 @@ typedef struct static __thread CoroutineWin32 leader; static __thread Coroutine *current; +__attribute__ ((noinline)) CoroutineAction qemu_coroutine_switch(Coroutine *from_, Coroutine *to_, CoroutineAction action) {