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

NaN passed to gcvt #1837

Closed
p5pRT opened this issue Apr 14, 2000 · 10 comments
Closed

NaN passed to gcvt #1837

p5pRT opened this issue Apr 14, 2000 · 10 comments

Comments

@p5pRT
Copy link

p5pRT commented Apr 14, 2000

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

Searchable as RT3100$

@p5pRT
Copy link
Author

p5pRT commented Apr 14, 2000

From gin@mo.msk.ru

Created by gin@mo.msk.ru

lib/bigfltpm test fails in step 351. `perl' passes a NaN value to
gcvt(), which causes it to get SIGFPE and dump core. gdb backtrace
follows.

#0 0x80019223 in PL_regflags ()
#1 0x80f721d in cvt ()
#2 0x80f71ae in ecvt ()
#3 0x80f7025 in gcvt ()
#4 0x80aa5bb in Perl_sv_2pv (sv=0x811cb50, lp=0x804787c) at sv.c​:2114
#5 0x80a23ce in Perl_pp_match () at pp_hot.c​:956
#6 0x809f74c in Perl_runops_standard () at run.c​:27
#7 0x805bd66 in S_run_body (oldscope=1) at perl.c​:1401
#8 0x805ba3b in perl_run (my_perl=0x8116804) at perl.c​:1325
#9 0x80590ee in main (argc=2, argv=0x8047b18, env=0x8047b24) at perlmain.c​:52
#10 0x8058feb in .text ()

Hex dump of double value in question is​:

0x00 0x00 0x00 0x00 0x00 0x00 0xf8 0x7f

It always causes my gcvt to get SIGFPE, regardless of program which
passed such an arg to it.

I do not know, is such a behavior of perl considered proper (and gcvt
must handle NaN's) or it is a bug in perl.

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl v5.6.0:

Configured by gin at Fri Apr 14 15:07:46 MSD 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=sco, osvers=3.2v5.0.2, archname=i386-sco
    uname='sco_sv d-fens 3.2 2 i386 '
    config_args='-de'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='cc', optimize='-O0', gccversion=
    cppflags='-U M_XENIX -D PERL_SCO -D PERL_SCO5 -w0 -belf -I/usr/local/include'
    ccflags ='-U M_XENIX -D PERL_SCO -D PERL_SCO5 -w0 -belf -g -I/usr/local/include'
    stdchar='unsigned char', d_stdstdio=undef, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=undef, longlongsize=, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=4
    alignbytes=4, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='ld', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
    libs=-lintl -lsocket -lnsl -lndbm -ldbm -lld -lm -lc -lcrypt -lsec -lPW -lx
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-Bexport -L/usr/local/lib'
    cccdlflags='-Kpic', lddlflags='-G -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.6.0:
    lib
    /usr/local/lib/perl5/5.6.0/i386-sco
    /usr/local/lib/perl5/5.6.0
    /usr/local/lib/perl5/site_perl/5.6.0/i386-sco
    /usr/local/lib/perl5/site_perl/5.6.0
    /usr/local/lib/perl5/site_perl
    .


Environment for perl v5.6.0:
    HOME=/home/gin
    LANG=C_C.C
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=.:/home/gin/pbin:/bin:/usr/bin:/usr/local/bin:/usr/merge/dosroot/ubin:/usr/bin/X11:/home/gin/bin
    PERL_BADLANG (unset)
    SHELL=/bin/sh


@p5pRT
Copy link
Author

p5pRT commented Apr 16, 2000

From [Unknown Contact. See original ticket]

One possible solution of gcvt SIGFPE problem is using sprintf instead
(in Gconvert macro). It runs normally and returns "nan". After
fixing config.sh this way and rebuilding perl all tests succeed.

This problem is specific to 5.0.2 or earlier versions. Perhaps this
explains why it was not detected before​: perl is likely to have been
ported only on 5.0.4 or later (-Bexport cc flag is valid only there).

@p5pRT
Copy link
Author

p5pRT commented Apr 28, 2000

From @gsar

On Fri, 14 Apr 2000 17​:32​:06, gin@​mo.msk.ru wrote​:

It always causes my gcvt to get SIGFPE, regardless of program which
passed such an arg to it.

I do not know, is such a behavior of perl considered proper (and gcvt
must handle NaN's) or it is a bug in perl.

Your platform likely needs to disable SIGFPE. See the end of unixish.h
for examples.

Sarathy
gsar@​activestate.com

@p5pRT
Copy link
Author

p5pRT commented Dec 14, 2004

From @schwern

Is this still an issue with 5.8.6?

@p5pRT
Copy link
Author

p5pRT commented Dec 14, 2004

@schwern - Status changed from 'open' to 'stalled'

@p5pRT
Copy link
Author

p5pRT commented Dec 15, 2004

From gin@mo.msk.ru

Again, already posted the solution (<023a38fa0f7b94-gin@​mo.msk.ru>).
`Gconvert' must be implemented on version 5.0.2 or earlier using
`sprintf', not `gcvt'. Again, check `hints/sco5.sh' or whatever sets
default values for `Configure' on that system.

Moreover, one can reproduce the way `Gconvert' is called by batcktrace
from original bug report (<023a38f7561586-gin@​mo.msk.ru>) and write a
test to be used by `Configure' / `hints' script to check how to
implement `Gconvert' properly.

@p5pRT
Copy link
Author

p5pRT commented Dec 15, 2004

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

@p5pRT
Copy link
Author

p5pRT commented Dec 15, 2004

From @doughera88

On Tue, 14 Dec 2004, Ilya N. Golubev wrote​:

Again, already posted the solution (<023a38fa0f7b94-gin@​mo.msk.ru>).
`Gconvert' must be implemented on version 5.0.2 or earlier using
`sprintf', not `gcvt'. Again, check `hints/sco5.sh' or whatever sets
default values for `Configure' on that system.

Yes, that's in the bug database.

However, the solution Sarathy suggested (ignoring SIGFPE) is also probably
already implemented in 5.8.6 (see the end of perl.h), though I don't know
if that implementation is working on SCO 5.0.2, and I expect nobody is in
a position to test it.

Moreover, one can reproduce the way `Gconvert' is called by batcktrace
from original bug report (<023a38f7561586-gin@​mo.msk.ru>) and write a
test to be used by `Configure' / `hints' script to check how to
implement `Gconvert' properly.

Configure does indeed contain a framework for testing various inputs to
the Gconvert function and verifying that they work, but that framework
doesn't handle NaN values, so it's not trivial to simply add in your
suggested test. It's a good suggestion, but would take a bit of work.

Still, the following patch should be harmless and safe to apply. It
simply instructs Configure to prefer sprintf() on SCO.

Inline Patch
diff -r -u perl-current/hints/sco.sh perl-andy/hints/sco.sh
--- perl-current/hints/sco.sh	Sun Jun 24 10:21:37 2001
+++ perl-andy/hints/sco.sh	Wed Dec 15 10:13:25 2004
@@ -201,6 +201,15 @@
 fi

 ###############################################################
+# At least for ORS5.0.2, prefer sprintf() over gcvt(), since gcvt()
+# used to cause a SIGFPE and a core dump when passed a NaN.
+# This may not be an issue in perl-5.8.x and later since we
+# try to trap SIGFPE.  However, preferring sprintf() should be
+# safe anyway, so let's go ahead and set it.  See the bugs database
+# item [perl #3100].   --A.D. 12/2004.
+	gconvert_preference='sprintf'
+
+###############################################################
 # We disable ODBM_File if OSR5 because it's mostly broken
 # but keep it for ODT3 as it seems to work.
 if test "$scorls" = "5"; then

-- 

  Andy Dougherty doughera@​lafayette.edu

@p5pRT
Copy link
Author

p5pRT commented Dec 15, 2004

From @rgs

Andy Dougherty wrote​:

Still, the following patch should be harmless and safe to apply. It
simply instructs Configure to prefer sprintf() on SCO.

diff -r -u perl-current/hints/sco.sh perl-andy/hints/sco.sh
--- perl-current/hints/sco.sh Sun Jun 24 10​:21​:37 2001
+++ perl-andy/hints/sco.sh Wed Dec 15 10​:13​:25 2004

Thanks, applied as #23655.

@p5pRT p5pRT closed this as completed Dec 15, 2004
@p5pRT
Copy link
Author

p5pRT commented Dec 15, 2004

@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
Projects
None yet
Development

No branches or pull requests

1 participant