Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.85k stars 527 forks source link

IsUV vanished in 5.7.0 #2581

Closed p5pRT closed 20 years ago

p5pRT commented 23 years ago

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

Searchable as RT4248$

p5pRT commented 23 years ago

From @jhi

Created by jhi@kosh.hut.fi

In Digital UNIX the IsUV flag somehow vanished between 5.6.0 and 5.7.0.

$ LD_LIBRARY_PATH=$PWD ./perl -Ilib -MDevel​::Peek -e '$a = 9223372036854775807;print Dump($a)' SV = IV(0x140013cf8) at 0x140013870   REFCNT = 1   FLAGS = (IOK\,pIOK)   IV = 9223372036854775807 $

No IsUV in FLAGS. Now watch the same with 5.6.0​:

$ perl -MDevel​::Peek -e '$a = 9223372036854775807;print Dump($a)' SV = IV(0x140014100) at 0x140022900   REFCNT = 1   FLAGS = (IOK\,pIOK\,IsUV)   UV = 9223372036854775808 $

The IsUV knowledge is there\, it works with constants​:

$ LD_LIBRARY_PATH=$PWD ./perl -Ilib -MDevel​::Peek -e 'print Dump(9223372036854775808)' SV = IV(0x140013cf0) at 0x140001af0   REFCNT = 1   FLAGS = (IOK\,READONLY\,pIOK\,IsUV)   UV = 9223372036854775808

The bug is OS-specific since in Solaris with 5.7.0​:

$ perl -MDevel​::Peek -e '$a=2147483648;print Dump($a)' SV = IV(0xffc7c) at 0x100834   REFCNT = 1   FLAGS = (IOK\,pIOK\,IsUV)   UV = 2147483648

Perl Info ``` Flags: category=core severity=medium Site configuration information for perl v5.7.0: Configured by jhi at Mon Sep 4 04:25:06 EET DST 2000. Summary of my perl5 (revision 5.0 version 7 subversion 0) configuration: Platform: osname=dec_osf, osvers=4.0f, archname=alpha-dec_osf uname='osf1 kosh.hut.fi v4.0 1229 alpha ' config_args='-des -Dusedevel' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef use64bitint=define use64bitall=define uselongdouble=undef Compiler: cc='cc', ccflags ='-std -fprm d -ieee -D_INTRINSICS -DLANGUAGE_C', optimize='-O4', cppflags='-std -ieee -D_INTRINSICS -DLANGUAGE_C' ccversion='V5.9-010', gccversion='', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, usemymalloc=y, prototype=define Linker and Libraries: ld='ld', ldflags ='' libpth=/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /var/shlib libs=-lgdbm -ldbm -ldb -lm -liconv -lutil libc=/usr/shlib/libc.so, so=so, useshrplib=true, libperl=libperl.so Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' -Wl,-rpath,/usr/local/lib/perl5/5.7.0/alpha-dec_osf/CORE' cccdlflags=' ', lddlflags='-shared -expect_unresolved "*" -O4 -msym -std -s' Locally applied patches: @INC for perl v5.7.0: lib /u/vieraat/vieraat/jhi/Perl/lib /usr/local/lib/perl5/5.7.0/alpha-dec_osf /usr/local/lib/perl5/5.7.0 /usr/local/lib/perl5/site_perl/5.7.0/alpha-dec_osf /usr/local/lib/perl5/site_perl/5.7.0 /usr/local/lib/perl5/site_perl . Environment for perl v5.7.0: HOME=/u/vieraat/vieraat/jhi LANG=C LANGUAGE (unset) LC_ALL=fi_FI.ISO8859-1 LC_CTYPE=fi_FI.ISO8859-1 LD_LIBRARY_PATH=/u/vieraat/vieraat/jhi/pp4/perl LOGDIR (unset) PATH=/u/vieraat/vieraat/jhi/Perl/bin:/u/vieraat/vieraat/jhi/.s:/u/vieraat/vieraat/jhi/.b/OSF1:/c/bin:/p/bin:/p/adm/bin:/usr/bin:/usr/sbin:/sbin:/bin:/usr/ccs/bin:/usr/lib:/etc:/lib:/p/X6/bin:/p/X5/bin:/usr/bin/X11:/usr/lbin:/usr/sbin/acct:/usr/tcb/bin:/tcb/bin:/usr/field:/u/vieraat/vieraat/jhi PERLLIB=/u/vieraat/vieraat/jhi/Perl/lib PERL_BADLANG (unset) SHELL=/bin/zsh ```
p5pRT commented 23 years ago

From @jhi

In Digital UNIX the IsUV flag somehow vanished between 5.6.0 and 5.7.0.

Please ignore/close the bug report since it's a *good* thing that the IsUV vanished from the below example​: that is according to the plan. It is a good thing that Perl prefers IVs over UVs (why? because many things in the internals have been optimized for IVs\, not UVs). Move along\, there is nothing in here for you to see.

Perhaps I really shouldn't touch the code before my vacation... :-)

$ LD_LIBRARY_PATH=$PWD ./perl -Ilib -MDevel​::Peek -e '$a = 9223372036854775807;print Dump($a)' SV = IV(0x140013cf8) at 0x140013870 REFCNT = 1 FLAGS = (IOK\,pIOK) IV = 9223372036854775807 $

p5pRT commented 23 years ago

From [Unknown Contact. See original ticket]

Jarkko Hietaniemi \jhi@​cc\.hut\.fi wrote

In Digital UNIX the IsUV flag somehow vanished between 5.6.0 and 5.7.0.

$ LD_LIBRARY_PATH=$PWD ./perl -Ilib -MDevel​::Peek -e '$a = 9223372036854775807;print Dump($a)' SV = IV(0x140013cf8) at 0x140013870 REFCNT = 1 FLAGS = (IOK\,pIOK) IV = 9223372036854775807   ^^^ $

No IsUV in FLAGS. Now watch the same with 5.6.0​:

$ perl -MDevel​::Peek -e '$a = 9223372036854775807;print Dump($a)' SV = IV(0x140014100) at 0x140022900 REFCNT = 1 FLAGS = (IOK\,pIOK\,IsUV) UV = 9223372036854775808   ^^^ $

You may have decided that this change isn't a bug\, but what about the change in numerical value? Presumably 5.6.0 was broken?

Mike Guy

p5pRT commented 23 years ago

From @jhi

$ LD_LIBRARY_PATH=$PWD ./perl -Ilib -MDevel​::Peek -e '$a = 9223372036854775807;print Dump($a)' SV = IV(0x140013cf8) at 0x140013870 REFCNT = 1 FLAGS = (IOK\,pIOK) IV = 9223372036854775807 ^^^ $

No IsUV in FLAGS. Now watch the same with 5.6.0​:

$ perl -MDevel​::Peek -e '$a = 9223372036854775807;print Dump($a)' SV = IV(0x140014100) at 0x140022900 REFCNT = 1 FLAGS = (IOK\,pIOK\,IsUV) UV = 9223372036854775808 ^^^ $

You may have decided that this change isn't a bug\, but what about the change in numerical value? Presumably 5.6.0 was broken?

Sharp eyes\, I must have missed that one because since I was only staring at the IsUV flag. Yes\, 5.6.0 was definitely broken also in this sense. It seems that the conversion is really\, *really*\, broken (lossy)​:

$ perl -MDevel​::Peek -le '$a = 9223372036854775800;print Dump($a);print $a' SV = IV(0x140014cf8) at 0x140028d28   REFCNT = 1   FLAGS = (IOK\,pIOK\,IsUV)   UV = 9223372036854775808

9223372036854775808 $

Must be going through NVs or something....(IV eq long eq 64 bits in Digital UNIX so no strtol/strtoul could create mess like that). I think I will add some tests to 64bitint to guard against this happening again in future.

p5pRT commented 20 years ago

From The RT System itself

note that 5.6.0 had it wrong\, now there are tests in op/64bitint to guard against the badness coming back.