Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bleadperl: abs() busted outside integer range #8057

Closed
p5pRT opened this issue Aug 6, 2005 · 9 comments
Closed

Bleadperl: abs() busted outside integer range #8057

p5pRT opened this issue Aug 6, 2005 · 9 comments

Comments

@p5pRT
Copy link

p5pRT commented Aug 6, 2005

Migrated from rt.perl.org#36819 (status was 'resolved')

Searchable as RT36819$

@p5pRT
Copy link
Author

p5pRT commented Aug 6, 2005

From shouldbedomo@mac.com

This is a bug report for perl from domo@​computer.org,
generated with the help of perlbug 1.35 running under perl vv5.9.3.


Bleadperl gets abs() wrong for all numbers larger than the narrower
of INT_MAX
or the mantissa of a double.

This is not a compiler issue​: I've tried both gcc-3.3 and 4.0.

For (32-bit) bleadperl@​25269​:
$ ./miniperl -lwe 'print(abs) for (0, -1e-200 * 1e-200, 1, -1,
2**31, -2**31, 2**32, -2**32, 2**52, -2**52, 2**63, -2**63,
2**64, -2**64, 1e50, -1e50, 1e200*1e200, 1e200*-1e200);'
0
0
1
1
2147483648
2147483648
-4294967296
-4294967296
-4.5035996273705e+15
-4.5035996273705e+15
-9.22337203685478e+18
-9.22337203685478e+18
-1.84467440737096e+19
-1.84467440737096e+19
-1e+50
-1e+50
-inf
-inf

For perl5.8.7​:
0
0
1
1
2147483648
2147483648
4294967296
4294967296
4.5035996273705e+15
4.5035996273705e+15
9.22337203685478e+18
9.22337203685478e+18
1.84467440737096e+19
1.84467440737096e+19
1e+50
1e+50
inf
inf

For a slightly down-rev 64-bit perl (bleadperl@​24148)​:
0
0
1
1
2147483648
2147483648
4294967296
4294967296
4503599627370496
4503599627370496
-9.22337203685478e+18
-9.22337203685478e+18
-1.84467440737096e+19
-1.84467440737096e+19
-1e+50
-1e+50
-inf
-inf



Flags​:
  category=core
  severity=medium


Site configuration information for perl vv5.9.3​:

Configured by domo at Sat Aug 6 12​:39​:59 CEST 2005.

Summary of my perl5 (revision 5 version 9 subversion 3 patch 25269)
configuration​:
  Platform​:
  osname=darwin, osvers=8.2.0, archname=darwin-thread-multi-2level
  uname='darwin tullamore.local 8.2.0 darwin kernel version 8.2.0​:
fri jun 24 17​:46​:54 pdt 2005; root​:xnu-792.2.4.obj~3release_ppc power
macintosh powerpc '
  config_args='-de -Doptimize=-g -Dusethreads -Dusedevel'
  hint=recommended, useposix=true, d_sigaction=define
  usethreads=define useithreads=define usemultiplicity=define
  useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
  use64bitint=undef use64bitall=undef uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp -
DDEBUGGING -fno-strict-aliasing -pipe -Wdeclaration-after-statement -
I/usr/local/include',
  optimize='-g',
  cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-
precomp -DDEBUGGING -fno-strict-aliasing -pipe -Wdeclaration-after-
statement -I/usr/local/include'
  ccversion='', gccversion='4.0.0 (Apple Computer, Inc. build
5026)', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  ivtype='long', ivsize=4, nvtype='double', nvsize=8,
Off_t='off_t', lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -L/usr/
local/lib'
  libpth=/usr/local/lib /usr/lib
  libs=-ldbm -ldl -lm -lc
  perllibs=-ldl -lm -lc
  libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false,
libperl=libperl.a
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
  cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/
usr/local/lib'

Locally applied patches​:


@​INC for perl vv5.9.3​:
  lib
  /sw/lib/perl5
  /sw/lib/perl5/darwin
  /usr/local/lib/perl5/5.9.3/darwin-thread-multi-2level
  /usr/local/lib/perl5/5.9.3
  /usr/local/lib/perl5/site_perl/5.9.3/darwin-thread-multi-2level
  /usr/local/lib/perl5/site_perl/5.9.3
  /usr/local/lib/perl5/site_perl
  .


Environment for perl vv5.9.3​:
  DYLD_LIBRARY_PATH (unset)
  HOME=/Users/domo
  LANG (unset)
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/Users/domo/bin​:/usr/local/bin​:/sw/bin​:/sw/sbin​:/bin​:/sbin​:/
usr/bin​:/usr/sbin​:/usr/X11R6/bin
  PERL5LIB=/sw/lib/perl5​:/sw/lib/perl5/darwin
  PERL5_CPANPLUS_CONFIG=/sw/lib/perl5/site_perl/5.8.4/CPANPLUS/
Config.pm
  PERL_BADLANG (unset)
  SHELL=/bin/bash

--
Dominic Dunlop

@p5pRT
Copy link
Author

p5pRT commented Aug 6, 2005

From shouldbedomo@mac.com

[As I write, this bug report has yet to hit p5p. I hope this follow-
up follows it to the list. Anyway ...]

I wrote​:

Bleadperl gets abs() wrong for all numbers larger than the narrower
of INT_MAX
or the mantissa of a double.

This is not a compiler issue​: I've tried both gcc-3.3 and 4.0.

For (32-bit) bleadperl@​25269​:
$ ./miniperl -lwe 'print(abs) for (0, -1e-200 * 1e-200, 1, -1,
2**31, -2**31, 2**32, -2**32, 2**52, -2**52, 2**63, -2**63,
2**64, -2**64, 1e50, -1e50, 1e200*1e200, 1e200*-1e200);'
0
0
1
1
2147483648
2147483648
-4294967296
-4294967296
-4.5035996273705e+15
-4.5035996273705e+15
-9.22337203685478e+18
-9.22337203685478e+18
-1.84467440737096e+19
-1.84467440737096e+19
-1e+50
-1e+50
-inf
-inf

The problem is a slip-up in the constification of pp.c. I attach a
patch to fix it, and to add tests for abs() to op/arith.t. I also
took the opportunity to soften the test script's hard dependency on
Config.pm. (The patch is larger than it deserves to be because abs()
needs testing early, and all the hardwired test numbers thereafter
needed to change.)
--
Dominic Dunlop

@p5pRT
Copy link
Author

p5pRT commented Aug 6, 2005

From shouldbedomo@mac.com

abs_patch

@p5pRT
Copy link
Author

p5pRT commented Aug 6, 2005

From @Tux

On Sat, 6 Aug 2005 16​:31​:37 +0200, Dominic Dunlop <shouldbedomo@​mac.com>
wrote​:

[As I write, this bug report has yet to hit p5p. I hope this follow-
up follows it to the list. Anyway ...]

I wrote​:

Bleadperl gets abs() wrong for all numbers larger than the narrower
of INT_MAX
or the mantissa of a double.

If I look at the patch, wouldn't it be an idea to take the opportunity to
make the test less count sentitive?

+# Give abs() a good work-out before using it in anger
+tryeq 5, abs(0), 0;
+tryeq 6, abs(1), 1;
+tryeq 7, abs(-1), 1;

=>

+# Give abs() a good work-out before using it in anger
+tryeq $T++, abs(0), 0;
+tryeq $T++, abs(1), 1;
+tryeq $T++, abs(-1), 1;

Or do you want the count indicators to be easily traceable?
Or is this test too basic to rely on $T++?

This is not a compiler issue​: I've tried both gcc-3.3 and 4.0.

For (32-bit) bleadperl@​25269​:
$ ./miniperl -lwe 'print(abs) for (0, -1e-200 * 1e-200, 1, -1,
2**31, -2**31, 2**32, -2**32, 2**52, -2**52, 2**63, -2**63,
2**64, -2**64, 1e50, -1e50, 1e200*1e200, 1e200*-1e200);'
0
0
1
1
2147483648
2147483648
-4294967296
-4294967296
-4.5035996273705e+15
-4.5035996273705e+15
-9.22337203685478e+18
-9.22337203685478e+18
-1.84467440737096e+19
-1.84467440737096e+19
-1e+50
-1e+50
-inf
-inf

The problem is a slip-up in the constification of pp.c. I attach a
patch to fix it, and to add tests for abs() to op/arith.t. I also
took the opportunity to soften the test script's hard dependency on
Config.pm. (The patch is larger than it deserves to be because abs()
needs testing early, and all the hardwired test numbers thereafter
needed to change.)

--
H.Merijn Brand Amsterdam Perl Mongers (http​://amsterdam.pm.org/)
using Perl 5.6.2, 5.8.0, 5.8.5, & 5.9.2 on HP-UX 10.20, 11.00 & 11.11,
AIX 4.3 & 5.2, SuSE 9.2 & 9.3, and Cygwin. http​://www.cmve.net/~merijn
Smoking perl​: http​://www.test-smoke.org, perl QA​: http​://qa.perl.org
reports to​: smokers-reports@​perl.org, perl-qa@​perl.org

@p5pRT
Copy link
Author

p5pRT commented Aug 6, 2005

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Aug 6, 2005

From shouldbedomo@mac.com

On 2005â??08â??06, at 17​:03, H.Merijn Brand wrote​:

If I look at the patch, wouldn't it be an idea to take the
opportunity to
make the test less count sentitive?

+# Give abs() a good work-out before using it in anger
+tryeq 5, abs(0), 0;
+tryeq 6, abs(1), 1;
+tryeq 7, abs(-1), 1;

=>

+# Give abs() a good work-out before using it in anger
+tryeq $T++, abs(0), 0;
+tryeq $T++, abs(1), 1;
+tryeq $T++, abs(-1), 1;

Good point.

Or do you want the count indicators to be easily traceable?

There is that. No. Let's make the thing more maintainable. Reworked
replacement for complete patch attached.

Or is this test too basic to rely on $T++?

Nah. base.lex.t does exactly what you suggest, so we can rely on it
by the time we hit anything in comp.
--
Dominic Dunlop

@p5pRT
Copy link
Author

p5pRT commented Aug 6, 2005

From shouldbedomo@mac.com

abs_patch

@p5pRT
Copy link
Author

p5pRT commented Aug 6, 2005

From @Tux

On Sat, 6 Aug 2005 17​:47​:40 +0200, Dominic Dunlop <shouldbedomo@​mac.com>
wrote​:

On 2005â��08â��06, at 17​:03, H.Merijn Brand wrote​:

If I look at the patch, wouldn't it be an idea to take the
opportunity to
make the test less count sentitive?

+# Give abs() a good work-out before using it in anger
+tryeq 5, abs(0), 0;
+tryeq 6, abs(1), 1;
+tryeq 7, abs(-1), 1;

=>

+# Give abs() a good work-out before using it in anger
+tryeq $T++, abs(0), 0;
+tryeq $T++, abs(1), 1;
+tryeq $T++, abs(-1), 1;

Good point.

Or do you want the count indicators to be easily traceable?

There is that. No. Let's make the thing more maintainable. Reworked
replacement for complete patch attached.

Thanks, applied as change #25270

Or is this test too basic to rely on $T++?

Nah. base.lex.t does exactly what you suggest, so we can rely on it
by the time we hit anything in comp.

--
H.Merijn Brand Amsterdam Perl Mongers (http​://amsterdam.pm.org/)
using Perl 5.6.2, 5.8.0, 5.8.5, & 5.9.2 on HP-UX 10.20, 11.00 & 11.11,
AIX 4.3 & 5.2, SuSE 9.2 & 9.3, and Cygwin. http​://www.cmve.net/~merijn
Smoking perl​: http​://www.test-smoke.org, perl QA​: http​://qa.perl.org
reports to​: smokers-reports@​perl.org, perl-qa@​perl.org

@p5pRT
Copy link
Author

p5pRT commented Aug 6, 2005

@rgs - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant