From owner-freebsd-stable@FreeBSD.ORG Fri Nov 16 20:35:15 2007 Return-Path: Delivered-To: stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D992B16A41A; Fri, 16 Nov 2007 20:35:15 +0000 (UTC) (envelope-from peterjeremy@optushome.com.au) Received: from mail14.syd.optusnet.com.au (mail14.syd.optusnet.com.au [211.29.132.195]) by mx1.freebsd.org (Postfix) with ESMTP id 6A2CF13C44B; Fri, 16 Nov 2007 20:35:15 +0000 (UTC) (envelope-from peterjeremy@optushome.com.au) Received: from server.vk2pj.dyndns.org (c220-239-20-82.belrs4.nsw.optusnet.com.au [220.239.20.82]) by mail14.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id lAGKZDba006675 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 17 Nov 2007 07:35:13 +1100 Received: from server.vk2pj.dyndns.org (localhost.vk2pj.dyndns.org [127.0.0.1]) by server.vk2pj.dyndns.org (8.14.1/8.14.1) with ESMTP id lAGKZCRJ049761; Sat, 17 Nov 2007 07:35:12 +1100 (EST) (envelope-from peter@server.vk2pj.dyndns.org) Received: (from peter@localhost) by server.vk2pj.dyndns.org (8.14.1/8.14.1/Submit) id lAGKZCnL049751; Sat, 17 Nov 2007 07:35:12 +1100 (EST) (envelope-from peter) Date: Sat, 17 Nov 2007 07:35:12 +1100 From: Peter Jeremy To: Bruce Evans Message-ID: <20071116203512.GD20992@server.vk2pj.dyndns.org> References: <20071115062002.GK89746@server.vk2pj.dyndns.org> <20071115184615.GL20992@server.vk2pj.dyndns.org> <20071117025943.P64582@delplex.bde.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="5I6of5zJg18YgZEa" Content-Disposition: inline In-Reply-To: <20071117025943.P64582@delplex.bde.org> X-PGP-Key: http://members.optusnet.com.au/peterjeremy/pubkey.asc User-Agent: Mutt/1.5.16 (2007-06-09) Cc: stable@freebsd.org, bde@freebsd.org, Pete French Subject: Re: Float problen running i386 inary on amd64 X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Nov 2007 20:35:15 -0000 --5I6of5zJg18YgZEa Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Nov 17, 2007 at 04:53:22AM +1100, Bruce Evans wrote: >Behaviour like this should be expected on i386 but not on amd64. It >gives the well-known property of the sin() function, that sin(x) !=3D sin(= x) >for almost all x (!). It happens because expressions _may_ be evaluated >in extra precision (this is perfectly standard), so identical expressions= =20 >may sometimes be evaluated in different precisions even, or especially, >if they are on the same line. Thank you for your detailed analysis. Hwever, I believe you missed the critical point (I may have removed too much reference to the actual problem that Pete French saw): I can take a program that was statically compiled on FreeBSD/i386, run it in legacy (i386) mode on FreeBSD-6.3/amd64 and get different results. Another (admittedly contrived) example: jashank% uname -a = =20 FreeBSD jashank.vk2pj.dyndns.org 6.1-STABLE FreeBSD 6.1-STABLE #15: Wed Aug= 2 18:35:57 EST 2006 root@jashank.vk2pj.dyndns.org:/usr/obj/usr/src/sy= s/jashank i386 jashank% cat y.c #include double one =3D 1.0; double three =3D 3.0; double third =3D 1.0/3.0; int main(int argc, char **argv) { if (one/three =3D=3D third) puts("Equal"); else puts("NOT Equal"); return (0); } jashank% cc -O2 -fno-strict-aliasing -pipe -march=3Dathlon y.c -static -o= y jashank% ./y Equal jashank% /sbin/sha256 y SHA256 (y) =3D d44fe8c4c4b4beab6125ba603f2a34fa4d0280ff04d697e22594debf9efc= 9a1a jashank%=20 turion% uname -a FreeBSD turion.vk2pj.dyndns.org 6.2-STABLE FreeBSD 6.2-STABLE #30: Tue Jul = 31 20:29:49 EST 2007 root@turion.vk2pj.dyndns.org:/usr/obj/usr/src/sys/= turion amd64 turion% scp -p jashank:y . =20 y 100% 146KB 145.9KB/s 00:00= =20 turion% /sbin/sha256 y SHA256 (y) =3D d44fe8c4c4b4beab6125ba603f2a34fa4d0280ff04d697e22594debf9efc= 9a1a turion% ./y NOT Equal turion%=20 This is identical code being executed in supposedly equivalent environments giving different results. I believe the fix is to initialise the FPU using __INITIAL_NPXCW__ in ia32_setregs(), though I'm not sure how difficult this is in reality. --=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. --5I6of5zJg18YgZEa Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4 (FreeBSD) iD8DBQFHPf7//opHv/APuIcRAjUpAKDD7ALpNxKehry9KyiIscoNUPcTPACfTKnL Y+cceitfaXLAOg/jSS53/8M= =0/6f -----END PGP SIGNATURE----- --5I6of5zJg18YgZEa--