From owner-freebsd-hackers@FreeBSD.ORG Sun Jul 13 10:55:59 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 2511A1065674 for ; Sun, 13 Jul 2008 10:55:59 +0000 (UTC) (envelope-from peterjeremy@optushome.com.au) Received: from mail12.syd.optusnet.com.au (mail12.syd.optusnet.com.au [211.29.132.193]) by mx1.freebsd.org (Postfix) with ESMTP id A83868FC12 for ; Sun, 13 Jul 2008 10:55:58 +0000 (UTC) (envelope-from peterjeremy@optushome.com.au) Received: from server.vk2pj.dyndns.org (c122-106-215-175.belrs3.nsw.optusnet.com.au [122.106.215.175]) by mail12.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id m6DAtrL7022121 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 13 Jul 2008 20:55:55 +1000 Received: from server.vk2pj.dyndns.org (localhost.vk2pj.dyndns.org [127.0.0.1]) by server.vk2pj.dyndns.org (8.14.2/8.14.2) with ESMTP id m6DAtmeM056158; Sun, 13 Jul 2008 20:55:48 +1000 (EST) (envelope-from peter@server.vk2pj.dyndns.org) Received: (from peter@localhost) by server.vk2pj.dyndns.org (8.14.2/8.14.2/Submit) id m6DAtmGX056157; Sun, 13 Jul 2008 20:55:48 +1000 (EST) (envelope-from peter) Date: Sun, 13 Jul 2008 20:55:48 +1000 From: Peter Jeremy To: Dmitry Morozovsky Message-ID: <20080713105548.GA55221@server.vk2pj.dyndns.org> References: <20080704121833.J35668@woozle.rinet.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="1yeeQ81UyVL57Vl7" Content-Disposition: inline In-Reply-To: <20080704121833.J35668@woozle.rinet.ru> X-PGP-Key: http://members.optusnet.com.au/peterjeremy/pubkey.asc User-Agent: Mutt/1.5.18 (2008-05-17) Cc: 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 10:55:59 -0000 --1yeeQ81UyVL57Vl7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2008-Jul-04 13:01:11 +0400, Dmitry Morozovsky wrote: >It seems we step on a bug in gcc in RELENG_7/i386 > >It is triggered at least by profiling program which uses getopt(3): I think it's actually in the profiling initialisation code. If you try to run sample code under gdb, you can see that .mcount() is not preserving %ecx, though main() assumes it does. (gdb) disas $eip Dump of assembler code for function main: 0x080481d0 : lea 0x4(%esp),%ecx 0x080481d4 : and $0xfffffff0,%esp 0x080481d7 : pushl 0xfffffffc(%ecx) 0x080481da : push %ebp 0x080481db : mov %esp,%ebp 0x080481dd : push %ecx 0x080481de : sub $0x14,%esp 0x080481e1 : call 0x8051b50 <.mcount> 0x080481e6 : mov 0x4(%ecx),%eax 0x080481e9 : mov (%eax),%eax 0x080481eb : mov %eax,0x8(%esp) 0x080481ef : mov (%ecx),%eax 0x080481f1 : mov %eax,0x4(%esp) 0x080481f5 : movl $0x8066b0a,(%esp) 0x080481fc : call 0x8051b00 0x08048201 : mov $0x0,%eax 0x08048206 : add $0x14,%esp 0x08048209 : pop %ecx 0x0804820a : pop %ebp 0x0804820b : lea 0xfffffffc(%ecx),%esp 0x0804820e : ret =20 End of assembler dump. (gdb) x/10x $esp 0xbfbfeadc: 0x0804815f 0x00000001 0xbfbfeb08 0xbfbfeb10 0xbfbfeaec: 0x00000000 0x00000000 0x00000000 0x00000000 0xbfbfeafc: 0x00000000 0x00000000 (gdb) info regi eax 0xbfbfeb08 -1077941496 ecx 0x1e968 125288 edx 0x8051d1a 134552858 ebx 0x1 1 esp 0xbfbfeadc 0xbfbfeadc ebp 0xbfbfeb00 0xbfbfeb00 esi 0xbfbfeb10 -1077941488 edi 0x0 0 eip 0x80481d0 0x80481d0 eflags 0x282 642 cs 0x33 51 ss 0x3b 59 ds 0x3b 59 es 0x3b 59 fs 0x3b 59 gs 0x1b 27 =2E.. [step through .mcount] =2E.. (gdb) stepi main (argc=3DError accessing memory address 0x1b: Bad address. ) at x.c:4 4 printf("Hello %d %s\n", argc, argv[0]); (gdb) info regi eax 0x1 1 ecx 0x1b 27 edx 0x804815f 134512991 ebx 0x1 1 esp 0xbfbfeab0 0xbfbfeab0 ebp 0xbfbfeac8 0xbfbfeac8 esi 0xbfbfeb10 -1077941488 edi 0x0 0 eip 0x80481e6 0x80481e6 eflags 0x246 582 cs 0x33 51 ss 0x3b 59 ds 0x3b 59 es 0x3b 59 fs 0x3b 59 gs 0x1b 27 --=20 Peter Jeremy Please excuse any delays as the result of my ISP's inability to implement an MTA that is either RFC2821-compliant or matches their claimed behaviour. --1yeeQ81UyVL57Vl7 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (FreeBSD) iEYEARECAAYFAkh53zQACgkQ/opHv/APuIe+oQCfT/3JMk9dd+g/f1J9aFPaIfHZ yHAAn0VIKv3ROqEHkRstmkHaEsUE2YOV =5j3z -----END PGP SIGNATURE----- --1yeeQ81UyVL57Vl7--