From wkb@chello.nl  Thu Apr 13 11:33:44 2000
Return-Path: <wkb@chello.nl>
Received: from relay01.chello.nl (smtp.chello.nl [212.83.68.144])
	by hub.freebsd.org (Postfix) with ESMTP id 2B48237B88D
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 13 Apr 2000 11:33:33 -0700 (PDT)
	(envelope-from wkb@chello.nl)
Received: from chello.nl ([213.46.78.184]) by relay01.chello.nl
          (InterMail vK.4.02.00.00 201-232-116 license 99c8f334c649856e3f2cdadc4054e412)
          with ESMTP id <20000413183326.FNHR11608.relay01@chello.nl>
          for <FreeBSD-gnats-submit@freebsd.org>;
          Thu, 13 Apr 2000 20:33:26 +0200
Received: (from wkb@localhost)
	by chello.nl (8.9.3/8.9.3) id UAA01216;
	Thu, 13 Apr 2000 20:33:24 +0200 (CEST)
	(envelope-from wkb)
Message-Id: <200004131833.UAA01216@chello.nl>
Date: Thu, 13 Apr 2000 20:33:24 +0200 (CEST)
From: wkb@chello.nl
Reply-To: wkb@chello.nl
To: FreeBSD-gnats-submit@freebsd.org
Subject: float to double coredump on 3.4-stable
X-Send-Pr-Version: 3.2

>Number:         17984
>Category:       i386
>Synopsis:       coredumps due to incorrect FP handling
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    marcel
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Apr 13 11:40:00 PDT 2000
>Closed-Date:    Mon Jul 17 21:13:29 PDT 2000
>Last-Modified:  Mon Jul 17 21:14:11 PDT 2000
>Originator:     Wilko Bulte
>Release:        FreeBSD 3.4-STABLE i386
>Organization:
Private FreeBSD site - The Netherlands
>Environment:

	Any i386 3.4-stable box.

>Description:

	float to double conversions don't work right. 
	NOTE: this was taken of the -stable mailing list to mark the 
	      problem in the PR database.

	Original posters: Randall Hopper <aa8vb@ipass.net> (problem)
		          "Sean O'Connell" <sean@stat.Duke.EDU> (patch)
	

>How-To-Repeat:

     main()
     {
        float  f = FLT_MAX;
        double d;
        f = f * 2;
        d = f;
     }

Delete the "d=f" line and it doesn't core.  Put it in and it does
(floating-point exception).


>Fix:


Here's the fix, from 4.0, that Sean sent me.

--- npx.h.releng_3	Wed Apr 12 16:28:38 2000
+++ npx.h	Wed Apr 12 16:33:36 2000
@@ -85,54 +85,24 @@
 	u_char	sv_pad[64];	/* padding; used by emulators */
 };
 
-/* Intel prefers long real (53 bit) precision */
-#define	__iBCS_NPXCW__		0x262
-/* wfj prefers temporary real (64 bit) precision */
-#define	__386BSD_NPXCW__	0x362
 /*
- * bde prefers 53 bit precision and all exceptions masked.
- *
- * The standard control word from finit is 0x37F, giving:
+ * The hardware default control word for i387's and later coprocessors 
is
+ * 0x37F, giving:
  *
  *	round to nearest
  *	64-bit precision
  *	all exceptions masked.
  *
- * Now I want:
+ * We modify the affine mode bit and precision bits in this to give:
  *
  *	affine mode for 287's (if they work at all) (1 in bitfield 1<<12)
  *	53-bit precision (2 in bitfield 3<<8)
- *	overflow exception unmasked (0 in bitfield 1<<3)
- *	zero divide exception unmasked (0 in bitfield 1<<2)
- *	invalid-operand exception unmasked (0 in bitfield 1<<0).
  *
  * 64-bit precision often gives bad results with high level languages
  * because it makes the results of calculations depend on whether
  * intermediate values are stored in memory or in FPU registers.
- *
- * The "Intel" and wfj control words have:
- *
- *	underflow exception unmasked (0 in bitfield 1<<4)
- *
- * but that causes an unexpected exception in the test program 
'paranoia'
- * and makes denormals useless (DBL_MIN / 2 underflows).  It doesn't 
make
- * a lot of sense to trap underflow without trapping denormals.
- *
- * Later I will want the IEEE default of all exceptions masked.  See 
the
- * 0.0 math manpage for why this is better.  The 0.1 math manpage is 
empty.
  */
-#define	__BDE_NPXCW__		0x1272
-#define	__BETTER_BDE_NPXCW__	0x127f
-
-#ifdef __BROKEN_NPXCW__
-#ifdef __FreeBSD__
-#define	__INITIAL_NPXCW__	__386BSD_NPXCW__
-#else
-#define	__INITIAL_NPXCW__	__iBCS_NPXCW__
-#endif
-#else
-#define	__INITIAL_NPXCW__	__BDE_NPXCW__
-#endif
+#define	__INITIAL_NPXCW__	0x127F
 
 #ifdef KERNEL
 extern struct proc *npxproc;



>Release-Note:
>Audit-Trail:

From: Wilko Bulte <wkb@chello.nl>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: i386/17984: coredumps due to incorrect FP handling
Date: Thu, 13 Apr 2000 20:47:42 +0200

 Forgot to mention I tested this on my 3.4-stable machine and the Linux
 Acrobat4 now runs stable,
 no coredumps anymore
 
 W/
 
 
State-Changed-From-To: open->closed 
State-Changed-By: sheldonh 
State-Changed-When: Mon Apr 17 01:27:03 PDT 2000 
State-Changed-Why:  
The change is alrady in effect in 4.0-RELEASE and in 5.0-CURRENT. 
It probably doesn't make sense to change this so late in the  
RELENG_3 lifecycle. 

From: "Jose M. Alcaide" <jose@we.lc.ehu.es>
To: freebsd-gnats-submit@FreeBSD.org, wkb@chello.nl
Cc:  
Subject: Re: i386/17984: coredumps due to incorrect FP handling
Date: Mon, 17 Apr 2000 17:52:51 +0200

 I bumped into this problem yesterday, just after upgrading Acrobat
 to 4.05 (Acrobat 4.0 didn't work as plug-in for linux-netscape).
 I think that Sean's patch should have been applied to RELENG_3 before
 closing this PR, since it does not depend on any of the
 new features of RELENG_4 or HEAD, and it is a very simple patch.
 Don't forget that the print/acroread4 port will be broken for 3.5-RELEASE
 if this problem is not fixed for RELENG_3.
 
 -- JMA
 
State-Changed-From-To: closed->open 
State-Changed-By: wilko 
State-Changed-When: Mon Apr 24 07:22:56 PDT 2000 
State-Changed-Why:  
I've exchanged private email with Marcel., the 'owner' of the 
Linuxulator. He told me he plans to fix the Linuxulator for this problem. 
But he is waiting for his network/machine infrastructure to arrive in his 
new home in Ca.  

The patch listed in this PR is not the right thing to do in general, a fix 
in the Linux compatibility code is. Until Marcel gets time to do his thing 
the patch will get you things like Acrobat4 working (it does for me).  

Wilko 


Responsible-Changed-From-To: freebsd-bugs->marcel 
Responsible-Changed-By: wilko 
Responsible-Changed-When: Mon Apr 24 07:22:56 PDT 2000 
Responsible-Changed-Why:  
Marcel wants to fix this in the Linuxulator 

From: Jeroen Ruigrok van der Werven <jruigrok@via-net-works.nl>
To: Martin Cracauer <cracauer@cons.org>
Cc: "Jose M. Alcaide" <jose@we.lc.ehu.es>,
	Sheldon Hearn <sheldonh@uunet.co.za>, wc.bulte@chello.nl,
	FreeBSD Gnats <freebsd-gnats-submit@freebsd.org>,
	Bruce Evans <bde@freebsd.org>
Subject: Re: i386/17984: coredumps due to incorrect FP handling
Date: Wed, 21 Jun 2000 07:17:20 +0200

 -On [20000418 16:15], Martin Cracauer (cracauer@cons.org) wrote:
 >Personally, I will not maintain RELENG_3 anymore (and I don't have a
 >3.x machine to test changes on anymore), but on the other side, I
 >don't care about it either, so if you find a committer and agreement
 >with Bruce, no "release line stability" objections from me.
 
 Actually I am still maintaining RELENG_3 and I hated the fact that I
 couldn't get more MFC's done. =(((
 
 But trust me that I'll want to fix this bug since I am unable to view
 PDFs on my 3.4-S box for some time now.  So its personal. ;)
 
 I'll go test the patches/diffs from 4/5 on this box today and commit it
 if that's ok with Bruce.
 
 -- 
 Jeroen Ruigrok van der Werven          Network- and systemadministrator
 <jruigrok@via-net-works.nl>            VIA Net.Works The Netherlands
 BSD: Technical excellence at its best  http://www.via-net-works.nl
 Care-charmer Sleep, son of the sable Night, Brother to Death, in silent
 darkness born...
 

From: Martin Cracauer <cracauer@cons.org>
To: Jeroen Ruigrok van der Werven <jruigrok@via-net-works.nl>
Cc: Martin Cracauer <cracauer@cons.org>,
	"Jose M. Alcaide" <jose@we.lc.ehu.es>,
	Sheldon Hearn <sheldonh@uunet.co.za>, wc.bulte@chello.nl,
	FreeBSD Gnats <freebsd-gnats-submit@freebsd.org>,
	Bruce Evans <bde@freebsd.org>
Subject: Re: i386/17984: coredumps due to incorrect FP handling
Date: Wed, 21 Jun 2000 11:08:01 +0200

 In <20000621071720.H30672@lucifer.bart.nl>, Jeroen Ruigrok van der Werven wrote: 
 > -On [20000418 16:15], Martin Cracauer (cracauer@cons.org) wrote:
 > >Personally, I will not maintain RELENG_3 anymore (and I don't have a
 > >3.x machine to test changes on anymore), but on the other side, I
 > >don't care about it either, so if you find a committer and agreement
 > >with Bruce, no "release line stability" objections from me.
 > 
 > Actually I am still maintaining RELENG_3 and I hated the fact that I
 > couldn't get more MFC's done. =(((
 > 
 > But trust me that I'll want to fix this bug since I am unable to view
 > PDFs on my 3.4-S box for some time now.  So its personal. ;)
 
 It is not a bug, but a policy.  The bug is that the Linux emulator
 inherits FreeBSD's value for the default control word.
 
 Having said this, I can only repeat that I think you can just change
 3.x to default to masked exceptions.  Feedback on the issue in 4.x was
 almost all positive and no applications that I am aware of (and I
 watched) broke.
 
 Martin
 -- 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 Martin Cracauer <cracauer@cons.org> http://www.cons.org/cracauer/
 BSD User Group Hamburg, Germany     http://www.bsdhh.org/
 
State-Changed-From-To: open->closed 
State-Changed-By: marcel 
State-Changed-When: Mon Jul 17 21:13:29 PDT 2000 
State-Changed-Why:  
Patch applied. Thanks... 

http://www.freebsd.org/cgi/query-pr.cgi?pr=17984 
>Unformatted:
