From owner-freebsd-hackers@FreeBSD.ORG Sun Jul 13 14:01:14 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 44CFB106564A for ; Sun, 13 Jul 2008 14:01:14 +0000 (UTC) (envelope-from marck@rinet.ru) Received: from woozle.rinet.ru (woozle.rinet.ru [195.54.192.68]) by mx1.freebsd.org (Postfix) with ESMTP id CD25E8FC14 for ; Sun, 13 Jul 2008 14:01:13 +0000 (UTC) (envelope-from marck@rinet.ru) Received: from localhost (localhost [127.0.0.1]) by woozle.rinet.ru (8.14.2/8.14.2) with ESMTP id m6DE1CNS080589; Sun, 13 Jul 2008 18:01:12 +0400 (MSD) (envelope-from marck@rinet.ru) Date: Sun, 13 Jul 2008 18:01:12 +0400 (MSD) From: Dmitry Morozovsky To: Peter Jeremy In-Reply-To: <20080713105548.GA55221@server.vk2pj.dyndns.org> Message-ID: <20080713175927.R58331@woozle.rinet.ru> References: <20080704121833.J35668@woozle.rinet.ru> <20080713105548.GA55221@server.vk2pj.dyndns.org> X-NCC-RegID: ru.rinet X-OpenPGP-Key-ID: 6B691B03 MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.0 (woozle.rinet.ru [0.0.0.0]); Sun, 13 Jul 2008 18:01:12 +0400 (MSD) Cc: kan@freebsd.org, freebsd-hackers@freebsd.org, oleg@rinet.ru Subject: Re: profiling broken on RELENG_7/i386 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Jul 2008 14:01:14 -0000 On Sun, 13 Jul 2008, Peter Jeremy wrote: PJ> On 2008-Jul-04 13:01:11 +0400, Dmitry Morozovsky wrote: PJ> >It seems we step on a bug in gcc in RELENG_7/i386 PJ> > PJ> >It is triggered at least by profiling program which uses getopt(3): PJ> PJ> I think it's actually in the profiling initialisation code. If PJ> you try to run sample code under gdb, you can see that .mcount() PJ> is not preserving %ecx, though main() assumes it does. I see. However, I'm afraid we need knowledge of some gcc guru to bring the fix in. Alexander, could you please comment? PJ> PJ> (gdb) disas $eip PJ> Dump of assembler code for function main: PJ> 0x080481d0 : lea 0x4(%esp),%ecx PJ> 0x080481d4 : and $0xfffffff0,%esp PJ> 0x080481d7 : pushl 0xfffffffc(%ecx) PJ> 0x080481da : push %ebp PJ> 0x080481db : mov %esp,%ebp PJ> 0x080481dd : push %ecx PJ> 0x080481de : sub $0x14,%esp PJ> 0x080481e1 : call 0x8051b50 <.mcount> PJ> 0x080481e6 : mov 0x4(%ecx),%eax PJ> 0x080481e9 : mov (%eax),%eax PJ> 0x080481eb : mov %eax,0x8(%esp) PJ> 0x080481ef : mov (%ecx),%eax PJ> 0x080481f1 : mov %eax,0x4(%esp) PJ> 0x080481f5 : movl $0x8066b0a,(%esp) PJ> 0x080481fc : call 0x8051b00 PJ> 0x08048201 : mov $0x0,%eax PJ> 0x08048206 : add $0x14,%esp PJ> 0x08048209 : pop %ecx PJ> 0x0804820a : pop %ebp PJ> 0x0804820b : lea 0xfffffffc(%ecx),%esp PJ> 0x0804820e : ret PJ> End of assembler dump. PJ> (gdb) x/10x $esp PJ> 0xbfbfeadc: 0x0804815f 0x00000001 0xbfbfeb08 0xbfbfeb10 PJ> 0xbfbfeaec: 0x00000000 0x00000000 0x00000000 0x00000000 PJ> 0xbfbfeafc: 0x00000000 0x00000000 PJ> (gdb) info regi PJ> eax 0xbfbfeb08 -1077941496 PJ> ecx 0x1e968 125288 PJ> edx 0x8051d1a 134552858 PJ> ebx 0x1 1 PJ> esp 0xbfbfeadc 0xbfbfeadc PJ> ebp 0xbfbfeb00 0xbfbfeb00 PJ> esi 0xbfbfeb10 -1077941488 PJ> edi 0x0 0 PJ> eip 0x80481d0 0x80481d0 PJ> eflags 0x282 642 PJ> cs 0x33 51 PJ> ss 0x3b 59 PJ> ds 0x3b 59 PJ> es 0x3b 59 PJ> fs 0x3b 59 PJ> gs 0x1b 27 PJ> ... PJ> [step through .mcount] PJ> ... PJ> (gdb) stepi PJ> main (argc=Error accessing memory address 0x1b: Bad address. PJ> ) at x.c:4 PJ> 4 printf("Hello %d %s\n", argc, argv[0]); PJ> (gdb) info regi PJ> eax 0x1 1 PJ> ecx 0x1b 27 PJ> edx 0x804815f 134512991 PJ> ebx 0x1 1 PJ> esp 0xbfbfeab0 0xbfbfeab0 PJ> ebp 0xbfbfeac8 0xbfbfeac8 PJ> esi 0xbfbfeb10 -1077941488 PJ> edi 0x0 0 PJ> eip 0x80481e6 0x80481e6 PJ> eflags 0x246 582 PJ> cs 0x33 51 PJ> ss 0x3b 59 PJ> ds 0x3b 59 PJ> es 0x3b 59 PJ> fs 0x3b 59 PJ> gs 0x1b 27 PJ> PJ> -- PJ> Peter Jeremy PJ> Please excuse any delays as the result of my ISP's inability to implement PJ> an MTA that is either RFC2821-compliant or matches their claimed behaviour. PJ> Sincerely, D.Marck [DM5020, MCK-RIPE, DM3-RIPN] [ FreeBSD committer: marck@FreeBSD.org ] ------------------------------------------------------------------------ *** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- marck@rinet.ru *** ------------------------------------------------------------------------