Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #34549] t/op/trans.t failure on OpenBSD

6 views
Skip to first unread message

Steve Peters

unread,
Mar 22, 2005, 6:41:13 PM3/22/05
to bugs-bi...@rt.perl.org
# New Ticket Created by Steve Peters
# Please include the string: [perl #34549]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=34549 >


When running testing parrot-HEAD, I get a test failure in t/op/trans.t on
OpenBSD. Running the same tests on Linux seem to work just fine...

> perl -Ilib t/op/trans.t
1..19
ok 1 - sin
ok 2 - cos
ok 3 - tan
ok 4 - sec
ok 5 - atan
ok 6 - asin
ok 7 - acos
ok 8 - asec
ok 9 - cosh
ok 10 - sinh
ok 11 - tanh
ok 12 - sech
not ok 13 - atan2
# Failed test (t/op/trans.t at line 307)
# got: 'ok 1
# ok 2
# ok 3
# ok 4
# ok 5
# ok 6
# ok 7
# ok 8
# ok 9
# ok 10
# ok 11
# ok 12
# ok 13
# ok 14
# ok 15
# ok 16
# not 0.000000ok 17
# '
# expected: 'ok 1
# ok 2
# ok 3
# ok 4
# ok 5
# ok 6
# ok 7
# ok 8
# ok 9
# ok 10
# ok 11
# ok 12
# ok 13
# ok 14
# ok 15
# ok 16
# ok 17
# '
ok 14 - log2
ok 15 - log10
ok 16 - ln
ok 17 - exp
ok 18 - pow
ok 19 - sqrt
# Looks like you failed 1 tests of 19.


Leopold Toetsch

unread,
Mar 23, 2005, 10:29:27 AM3/23/05
to perl6-i...@perl.org
Steve Peters <parrotbug...@parrotcode.org> wrote:
> # New Ticket Created by Steve Peters
> # Please include the string: [perl #34549]
> # in the subject line of all future correspondence about this issue.
> # <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=34549 >


> When running testing parrot-HEAD, I get a test failure in t/op/trans.t on
> OpenBSD. Running the same tests on Linux seem to work just fine...

>> perl -Ilib t/op/trans.t


> not ok 13 - atan2
> # Failed test (t/op/trans.t at line 307)
> # got: 'ok 1

> # not 0.000000ok 17

atan N4, -0.0, -0.0

Obviously another broken C system. What says your perl:

$ perl -le'print atan2(-0.0,-0.0)'
-3.14159265358979324

leo

Steve Peters

unread,
Mar 23, 2005, 11:43:19 AM3/23/05
to Leopold Toetsch via RT

Tasty :-/

On OpenBSD, I get

> perl -le'print atan2(-0.0,-0.0)'
0

Steve

Leopold Toetsch

unread,
Mar 23, 2005, 1:00:16 PM3/23/05
to Steve Peters, perl6-i...@perl.org

> Tasty :-/

> On OpenBSD, I get

Time to start some more OS-specific docs that summarize such "features"?

> Steve

leo

Steve Peters

unread,
Mar 24, 2005, 8:48:04 AM3/24/05
to Leopold Toetsch via RT
Here's the responce from the OpenBSD folks. It seems that turning on a
define prior to the atan2() call will set the flags correctly for OpenBSD.
My guess is that NetBSD will behave similarly.

> >Number: 4154
> >Category: library
> >Synopsis: atan2(-0.0, -0.0) returning incorrect result

Our libm is compiled in multi mode and defaults to posix mode, which
sets errno and returns 0 if both args are (+-)0.0. IEEE mode does what you
want.

Check lib/libm/Makfile and lib/lib/src/{e,w}w_atan2.c for some background
info.

If you force libm to IEEE mode, you'll get the expected results:
(on macppc, same results on i386):

[otto@fonzo:9]$ cat x.c
#include <errno.h>
#include <stdio.h>
#include <math.h>

int main() {
double res;

_LIB_VERSION = _IEEE_;

errno = 0;
res = atan2(0.0, 0.0);
perror("atan2");
printf("atan2(0.0, 0.0) = %f\n", res);
errno = 0;
res = atan2(-0.0, 0.0);
perror("atan2");
printf("atan2(-0.0, 0.0) = %f\n", res);
errno = 0;
res = atan2(0.0, -0.0);
perror("atan2");
printf("atan2(0.0, -0.0) = %f\n", res);
errno = 0;
res = atan2(-0.0, -0.0);
perror("atan2");
printf("atan2(-0.0, -0.0) = %f\n", res);
}

[otto@fonzo:10]$ a.out
atan2: Undefined error: 0
atan2(0.0, 0.0) = 0.000000
atan2: Undefined error: 0
atan2(-0.0, 0.0) = 0.000000
atan2: Undefined error: 0
atan2(0.0, -0.0) = 3.141593
atan2: Undefined error: 0
atan2(-0.0, -0.0) = -3.141593
[otto@fonzo:11]$

----- End forwarded message -----

Leopold Toetsch

unread,
Mar 24, 2005, 9:37:03 AM3/24/05
to Steve Peters, perl6-i...@perl.org
Steve Peters <st...@fisharerojo.org> wrote:
> Here's the responce from the OpenBSD folks. It seems that turning on a
> define prior to the atan2() call will set the flags correctly for OpenBSD.

[ ... ]

> _LIB_VERSION = _IEEE_;

Fine. Thanks for the research. It should probably suffice to set the
_LIB_VERSION once. As this is platform-specific this belongs into

config/gen/platform/*bsd/init.c

where the new file init.c should contain a function

void Parrot_platform_init(Interp *i)
{
_LIB_VERSION = _IEEE_;
}

or some such. The fallback generic/init.c should do nothing. I think the
configure system will pick up these files automatically, we just have to
call the init function during interpreter startup.
Header definition should go into platform/platform_interface.h.

Comments, takers?

Do we need a test, if "_LIB_VERSION" is compiled into libm?

leo

Steve Peters via RT

unread,
Mar 24, 2005, 10:59:03 AM3/24/05
to perl6-i...@perl.org
> [leo - Thu Mar 24 07:07:31 2005]:
>
>
> Comments, takers?
>


Since I'm fixing this in Perl, I take a whack at it in Parrot as well.

Steve

Steve Peters via RT

unread,
Dec 29, 2005, 9:53:17 AM12/29/05
to perl6-i...@perl.org
> [stmpeters - Tue Mar 22 15:41:12 2005]:

>
> When running testing parrot-HEAD, I get a test failure in
t/op/trans.t on
> OpenBSD. Running the same tests on Linux seem to work just fine...
>
> > perl -Ilib t/op/trans.t
> 1..19
> ok 1 - sin
> ok 2 - cos
> ok 3 - tan
> ok 4 - sec
> ok 5 - atan
> ok 6 - asin
> ok 7 - acos
> ok 8 - asec
> ok 9 - cosh
> ok 10 - sinh
> ok 11 - tanh
> ok 12 - sech
> not ok 13 - atan2
> # Failed test (t/op/trans.t at line 307)
> # got: 'ok 1

Included below is a patch that fixes the above test failures on
OpenBSD. I've also included code to fix the problem on Cygwin (see
ticket #36835) although I could not get Cygwin to compile with or
without my patch. A similar solution will likely work on a gcc-
compiled Solaris, but I discuss that in the more recent ticket there.
I'm also guessing that NetBSD will require a similar patch, but I need
to get on a NetBSD machine a test my patch. Expect that patch later
today.

--- MANIFEST.old Thu Dec 29 00:03:32 2005
+++ MANIFEST Thu Dec 29 08:31:01 2005
@@ -189,6 +189,7 @@
config/gen/platform/ansi/dl.c []
config/gen/platform/ansi/exec.c []
config/gen/platform/ansi/io.h []
+config/gen/platform/cygwin/init.c []
config/gen/platform/ansi/time.c []
config/gen/platform/darwin/begin.c []
config/gen/platform/darwin/dl.c []
@@ -197,6 +198,7 @@
config/gen/platform/generic/dl.h []
config/gen/platform/generic/env.c []
config/gen/platform/generic/exec.c []
+config/gen/platform/generic/init.c []
config/gen/platform/generic/io.h []
config/gen/platform/generic/itimer.c []
config/gen/platform/generic/math.c []
@@ -210,6 +212,7 @@
config/gen/platform/generic/threads.h []
config/gen/platform/generic/time.c []
config/gen/platform/ia64/asm.s []
+config/gen/platform/openbsd/init.c []
config/gen/platform/openbsd/memexec.c []
config/gen/platform/openbsd/misc.h []
config/gen/platform/platform_interface.h []
--- /dev/null Thu Dec 29 05:43:20 2005
+++ config/gen/platform/generic/init.c Wed Dec 28 23:11:38 2005
@@ -0,0 +1,3 @@
+/* Placeholder for platform specific initializations (header includes,
+ * global variable initialization, etc.
+ */
--- /dev/null Thu Dec 29 05:43:38 2005
+++ config/gen/platform/openbsd/init.c Wed Dec 28 23:23:45 2005
@@ -0,0 +1,3 @@
+#include <math.h>
+
+_LIB_VERSION_TYPE _LIB_VERSION = _IEEE_;
--- /dev/null Thu Dec 29 05:43:38 2005
+++ config/gen/platform/cygwin/init.c Wed Dec 28 23:23:45 2005
@@ -0,0 +1,3 @@
+#include <math.h>
+
+const _LIB_VERSION_TYPE _LIB_VERSION = _IEEE_;

Joshua Hoblitt via RT

unread,
Dec 29, 2005, 6:29:26 PM12/29/05
to perl6-i...@perl.org
FYI - bugs #36835 & #38060 have been merged into #34549.

-J

--

Joshua Hoblitt via RT

unread,
Jan 1, 2006, 9:49:24 PM1/1/06
to perl6-i...@perl.org
I've commited a possible fix for openbsd, cygwin, & solaris as changesets
r10839 & r10843. I basically applied what Steve Peters proposed but
with the changes in math.c instead of creating init.c (as agreed to on
#parrot).

This doesn't appear to have done anything for gcc/solaris... can someone
test openbsd and cygwin?

-J

--

Greg Bacon

unread,
Jan 2, 2006, 10:01:55 AM1/2/06
to parrotbug...@parrotcode.org, perl6-i...@perl.org
In message <rt-3.0.11-34549-126...@perl.org>,
"Joshua Hoblitt via RT" writes:

: I've commited a possible fix for openbsd, cygwin, & solaris as changesets

After upping to r10844, trans.t still fails:

t/op/trans....1..19


ok 1 - sin
ok 2 - cos
ok 3 - tan
ok 4 - sec
ok 5 - atan
ok 6 - asin
ok 7 - acos
ok 8 - asec
ok 9 - cosh
ok 10 - sinh
ok 11 - tanh
ok 12 - sech

# Failed test (t/op/trans.t at line 313)


# got: 'ok 1
# ok 2
# ok 3
# ok 4
# ok 5
# ok 6
# ok 7
# ok 8
# ok 9
# ok 10
# ok 11
# ok 12
# ok 13
# ok 14
# ok 15
# ok 16

not ok 13 - atan2

# Looks like you failed 1 test of 19.
dubious
Test returned status 1 (wstat 256, 0x100)
DIED. FAILED test 13
Failed 1/19 tests, 94.74% okay
Failed Test Stat Wstat Total Fail Failed List of Failed
-------------------------------------------------------------------------------
t/op/trans.t 1 256 19 1 5.26% 13
Failed 1/1 test scripts, 0.00% okay. 1/19 subtests failed, 94.74% okay.

Steve Peters

unread,
Jan 2, 2006, 2:53:18 PM1/2/06
to gba...@hiwaay.net, parrotbug...@parrotcode.org, perl6-i...@perl.org
On Mon, Jan 02, 2006 at 09:01:55AM -0600, Greg Bacon wrote:
> In message <rt-3.0.11-34549-126...@perl.org>,
> "Joshua Hoblitt via RT" writes:
>
> : I've commited a possible fix for openbsd, cygwin, & solaris as changesets
> : r10839 & r10843. I basically applied what Steve Peters proposed but
> : with the changes in math.c instead of creating init.c (as agreed to on
> : #parrot).
> :
> : This doesn't appear to have done anything for gcc/solaris... can someone
> : test openbsd and cygwin?
>
> After upping to r10844, trans.t still fails:
>

What operating system are you using?

Steve Peters
st...@fisharerojo.org

Greg Bacon

unread,
Jan 3, 2006, 2:18:05 PM1/3/06
to Steve Peters, parrotbug...@parrotcode.org, perl6-i...@perl.org
In message <20060102195...@mccoy.peters.homeunix.org>,
Steve Peters writes:

: On Mon, Jan 02, 2006 at 09:01:55AM -0600, Greg Bacon wrote:
:
: > After upping to r10844, trans.t still fails:


:
: What operating system are you using?

Sorry. That report was for Cygwin.

Greg

Steve Peters via RT

unread,
Mar 21, 2006, 9:42:42 AM3/21/06
to perl6-i...@perl.org
> [jhoblitt - Sun Jan 01 18:49:23 2006]:

>
> I've commited a possible fix for openbsd, cygwin, & solaris as
changesets
> r10839 & r10843. I basically applied what Steve Peters proposed but
> with the changes in math.c instead of creating init.c (as agreed to on
> #parrot).
>
> This doesn't appear to have done anything for gcc/solaris... can someone
> test openbsd and cygwin?

These changes fixed OpenBSD and were used with NetBSD to allow it to
pass all of its tests. That leaves the issue open for Solaris and Cygwin.

Joshua Hoblitt

unread,
Mar 21, 2006, 4:01:19 PM3/21/06
to Steve Peters via RT, Bernhard.S...@gmx.de, par...@jensbeimsurfen.de

Fantastic. Thanks for the update.

Can someone test this on Cygwin?

-J

--

Joshua Isom

unread,
Mar 21, 2006, 6:12:02 PM3/21/06
to Joshua Hoblitt, p6i List
On OpenBSD 3.8 x86, I still get the failures with -0.0/0.0. Check the
smokes...

Joshua Hoblitt

unread,
Mar 21, 2006, 6:58:54 PM3/21/06
to Joshua Isom via RT, Bernhard.S...@gmx.de, par...@jensbeimsurfen.de, st...@fisharerojo.org
Steve,

What version of OpenBSD were you running (perhaps something old or
direct from CVS)?

-J

--

Joshua Isom

unread,
Mar 21, 2006, 8:45:48 PM3/21/06
to Joshua Hoblitt, p6i List
It seems I'm mistaking problems. OpenBSD does do atan2 correctly.
But, OpenBSD doesn't like printing "-0.0". It'll print it as positive.
I'm not sure how to get it to print -0 instead of +0.

Steve Peters

unread,
Nov 11, 2006, 12:35:53 PM11/11/06
to Joshua Hoblitt via RT, Bernhard.S...@gmx.de, jhob...@ifa.hawaii.edu, par...@jensbeimsurfen.de
On Sat, Nov 11, 2006 at 04:02:21AM -0800, Joshua Hoblitt via RT wrote:
> Is this issue considered resolved for BSD and/or has acceptable test
> coverage?
>
>
I believe that things were alright for both OpenBSD and NetBSD. Solaris
is still an issue. t/op/trans.t passes when run like

perl t/harness t/op/trans.t

but fails miserably when run like

perl t/harness -v t/op/trans.t

Steve Peters
st...@fisharerojo.org

Andrew Whitworth via RT

unread,
Jul 16, 2008, 1:33:10 PM7/16/08
to perl6-i...@perl.org
Is this still not resolved? This ticket has not seen any discussion
since 2006. To double-check, I think we need people to check
t/op/trans.t on:

*Solaris
*OpenBSD
*NetBSD
*Cygwin

If it passes all these platforms, I think the ticket is resolved. If
not, maybe we need to break this into more-specific sub-tickets for each
failing platform.

--Andrew Whitworth

Andy Dougherty

unread,
Jul 17, 2008, 4:15:02 PM7/17/08
to Andrew Whitworth via RT

It still fails in the identical way on Solaris 8/SPARC with gcc.

--
Andy Dougherty doug...@lafayette.edu

Steve Peters

unread,
Jul 18, 2008, 7:23:30 AM7/18/08
to parrotbug...@parrotcode.org, Bernhard.S...@gmx.de, jhob...@ifa.hawaii.edu, par...@jensbeimsurfen.de
Unfortunately, my changes to Perl 5 have been working better than my
changes to Parrot. IIRC, the changes made fixed OpenBSD and NetBSD on
Parrot while Cygwin and Solaris didn't seem to fare as well.

Steve

On Thu, Jul 17, 2008 at 7:29 PM, Thorsten Glaser via RT
<parrotbug...@parrotcode.org> wrote:


> On Wed Jul 16 10:33:06 2008, Whiteknight wrote:
>> Is this still not resolved?
>

> On MirBSD (perl $^O 'mirbsd'), whose libm is about 85% NetBSD,
> 15% OpenBSD, the Perl test succeeds.
>
> The following lines in perl/pp.c already trigger:
> 38 /*
> 39 * Some BSDs and Cygwin default to POSIX math instead of IEEE.
> 40 * This switches them over to IEEE.
> 41 */
> 42 #if defined(LIBM_LIB_VERSION)
> 43 _LIB_VERSION_TYPE _LIB_VERSION = _IEEE_;
> 44 #endif
>
> I _suspect_ this would work on OpenBSD and NetBSD as well,
> but it's better to check with actual users of the system.
> I got this via IRC from a NetBSD developer:
> 00:16│«replaced» $ perl -le'print atan2(-0.0,-0.0)'
> 00:16│«replaced» -3.14159265358979
>
> This matches mine:
> tg@odem:~ $ perl -le'print atan2(-0.0,-0.0)'
> -3.14159265358979
>
> I think the bit less of precision is due to us trying to
> avoid the i387 issue of intermediate high precision (the
> FPCW is initialised to low precision by the kernel, which
> may be a good thing).
>
> bye,
> //mirabilos
> --
> "Using Lynx is like wearing a really good pair of shades: cuts out
> the glare and harmful UV (ultra-vanity), and you feel so-o-o COOL."
> -- Henry Nelson, March 1999
>
>

0 new messages