Subject: port-alpha/10065: __divq(0x8000000000000000, 1) dies with SIGFPE
To: None <gnats-bugs@gnats.netbsd.org>
From: None <itohy@netbsd.org>
List: netbsd-bugs
Date: 05/07/2000 16:24:12
>Number: 10065
>Category: port-alpha
>Synopsis: __divq(0x8000000000000000, 1) dies with SIGFPE
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: port-alpha-maintainer
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun May 07 16:25:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: ITOH Yasufumi
>Release: 1.4X (April 28, 2000)
>Organization:
>Environment:
System: NetBSD libble.my.domain 1.4X NetBSD 1.4X (LIBBLE) #2: Mon May 1 01:01:21 JST 2000 itohy@libble.my.domain:/usr/src/sys/arch/alpha/compile/LIBBLE alpha
>Description:
__divq(0x8000000000000000, 1) causes SIGFPE
(note that __divq is not a normal function).
This causes failure on "make test" of gforth-0.4.0.
>How-To-Repeat:
Try following program.
% cc divqtest.c
% ./a.out
Floating point exception (core dumped)
%
Any combinations of arg1 and arg2 (!= 0) other than
0x8000000000000000 and 1 seem to work fine.
divqtest.c:
#include <stdio.h>
main()
{
register long arg1 asm("$24") = 0x8000000000000000;
register long arg2 asm("$25") = 1;
register long result asm("$27");
/*
* t10($24) / t11($25) -> t12($27)
* return addr is t9($23), not ra($26)
*/
asm("jsr $23,__divq" : "=r" (result) : "r" (arg1), "r" (arg2));
printf("result %lx\n", result);
return 0;
}
>Fix:
Do not raise interger overflow exception.
diff -u lib/libc/arch/alpha/gen/divrem.m4.orig lib/libc/arch/alpha/gen/divrem.m4
--- lib/libc/arch/alpha/gen/divrem.m4.orig Thu Oct 17 20:12:22 1996
+++ lib/libc/arch/alpha/gen/divrem.m4 Tue May 2 23:34:55 2000
@@ -171,7 +171,7 @@
ifelse(S, `true',
`
/* Check to see if we should negate it. */
- subqv zero, RESULT, T_0
+ subq zero, RESULT, T_0
cmovlbs NEG, T_0, RESULT
')
diff -u sys/lib/libkern/arch/alpha/divrem.m4.orig sys/lib/libkern/arch/alpha/divrem.m4
--- sys/lib/libkern/arch/alpha/divrem.m4.orig Thu Oct 17 20:21:07 1996
+++ sys/lib/libkern/arch/alpha/divrem.m4 Tue May 2 23:34:55 2000
@@ -171,7 +171,7 @@
ifelse(S, `true',
`
/* Check to see if we should negate it. */
- subqv zero, RESULT, T_0
+ subq zero, RESULT, T_0
cmovlbs NEG, T_0, RESULT
')
>Release-Note:
>Audit-Trail:
>Unformatted: