From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21753 invoked by alias); 4 Jan 2012 10:08:45 -0000 Received: (qmail 21598 invoked by uid 22791); 4 Jan 2012 10:08:43 -0000 X-SWARE-Spam-Status: No, hits=-0.6 required=5.0 tests=AWL,BAYES_00,MIME_CHARSET_FARAWAY,RCVD_IN_DNSWL_NONE,TW_PX X-Spam-Check-By: sourceware.org Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 04 Jan 2012 10:08:29 +0000 Received: from mail.yager.de (mail.yager.de [212.60.243.130]) by mx01.qsc.de (Postfix) with ESMTP id 5E7A73E5B5; Wed, 4 Jan 2012 11:08:27 +0100 (CET) Received: from hermes.corp.yager.de ([fe80::8de:db45:75d8:9f78]) by hermes.corp.yager.de ([fe80::8de:db45:75d8:9f78%12]) with mapi; Wed, 4 Jan 2012 11:08:27 +0100 From: Markus Henschel To: Andrew Haley , "gcc-help@gcc.gnu.org" Date: Wed, 04 Jan 2012 10:08:00 -0000 Subject: RE: Questions before submitting a bug report Message-ID: References: <4F031E24.7090402@redhat.com> <4F03241E.5050200@redhat.com> In-Reply-To: <4F03241E.5050200@redhat.com> Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2012-01/txt/msg00013.txt.bz2 > -----Original Message----- > From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On > Behalf Of Andrew Haley > Sent: Dienstag, 3. Januar 2012 16:52 > To: gcc-help@gcc.gnu.org > Subject: Re: Questions before submitting a bug report >=20 > On 01/03/2012 03:39 PM, Markus Henschel wrote: > >> -----Original Message----- > >> From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] > >> On Behalf Of Andrew Haley > >> Sent: Dienstag, 3. Januar 2012 16:26 > >> To: gcc-help@gcc.gnu.org > >> Subject: Re: Questions before submitting a bug report > >> > >> On 01/03/2012 03:02 PM, Markus Henschel wrote: > >>> Is there some obvious flaw in my code? > >> > >> What error did you get? Not all CPUs can do __sync_add_and_fetch on > >> a long long. > > > > The resulting program crashes with a segmentation fault on the line > with __sync_add_and_fetch. This is the complete command line I used for > compiling: > > > > "gcc -fPIC -march=3Di586 -fvisibility=3Dhidden -O3 mytest.c -o mytest" > > > > The error goes away if I remove "-fPIC", "-fvisibility=3Dhidden" or if > I use some less aggressive optimization. It also disappears if I use a > long instead of a long long. >=20 > I think you've found yourself a bug. I can't reproduce it, nor can I > see anything wrong with your code. It's be interesting to see what > instruction makes it crash. >=20 > Andrew. Thanks for having a look at this. To satisfy your curiosity here is the asm= output of gdb for an even simpler test case: int main(int argc, char * argv[]) { static long long foo; return __sync_add_and_fetch(&foo, foo); } I don't know if this is meaningful because I don't know much about assemble= r. =82=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80= =80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80= =80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80= =80=80=83 =810x8048350
lea 0x4(%esp),%ecx = =81 =810x8048354 and $0xfffffff0,%esp = =81 =810x8048357 pushl -0x4(%ecx) = =81 =810x804835a push %ebp = =81 =810x804835b mov %esp,%ebp = =81 =810x804835d push %edi = =81 =810x804835e push %esi = =81 =810x804835f push %ebx = =81 =810x8048360 push %ecx = =81 =810x8048361 call 0x8048366 = =81 =810x8048366 pop %ebx = =81 =810x8048367 add $0x1206,%ebx = =81 =810x804836d sub $0x8,%esp = =81 =810x8048370 mov 0x2c(%ebx),%eax = =81 =810x8048376 mov 0x30(%ebx),%edx = =81 =810x804837c mov %eax,%esi = =81 =810x804837e mov %edx,%edi = =81 =810x8048380 add 0x2c(%ebx),%esi = =81 =810x8048386 adc 0x30(%ebx),%edi = =81 =810x804838c mov %esi,-0x18(%ebp) = =81 =810x804838f mov %edi,-0x14(%ebp) = =81 =810x8048392 mov %esi,%edi = =81 =810x8048394 mov -0x14(%ebp),%ecx = =81 =810x8048397 xchg %ebx,%edi = =81 >=810x8048399 lock cmpxchg8b 0x2c(%ebx) = =81 =810x80483a1 xchg %ebx,%edi = =81 =810x80483a3 jne 0x804837c = =81 =810x80483a5 mov -0x18(%ebp),%eax = =81 =810x80483a8 pop %edx = =81 =84=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80= =80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80= =80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80=80= =80=80=85 child process 15488 In: main Line: ?? PC: 0x804= 8399=20 (gdb) run Starting program: /home/ubuntu/mytest=20 Program received signal SIGSEGV, Segmentation fault. 0x08048399 in main () If gcc 4.2 isn't maintained anymore I'll use a workaround and see that we c= an switch to a newer gcc release in the future.=20 Thank you for your time. Markus