Skip Menu |

This queue is for tickets about the Math-Int64 CPAN distribution.

Report information
The Basics
Id: 100861
Status: resolved
Priority: 0/
Queue: Math-Int64

People
Owner: Nobody in particular
Requestors: aleksey.mashanov [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Lost bit on an i386 platform
On an i386: $ perl -MMath::Int64=int64 -lwe 'print int64("-2251842763358208")' -42949672960 On a x86_64: $ perl -MMath::Int64=int64 -lwe 'print int64("-2251842763358208")' -2251842763358208 As I see bug is not in stringification. Problem remains when conversion to native format is used.
Subject: Re: [rt.cpan.org #100861] Lost bit on an i386 platform
Date: Thu, 11 Dec 2014 17:29:04 +0000 (UTC)
To: "bug-Math-Int64 [...] rt.cpan.org" <bug-Math-Int64 [...] rt.cpan.org>
From: Salvador Fandino <sfandino [...] yahoo.com>
Show quoted text
----- Original Message -----
> From: Aleksey Mashanov via RT <bug-Math-Int64@rt.cpan.org> > To: > Cc: > Sent: Thursday, December 11, 2014 4:00 PM > Subject: [rt.cpan.org #100861] Lost bit on an i386 platform > >T hu Dec 11 10:00:41 2014: Request 100861 was acted upon. > Transaction: Ticket created by amashanov > Queue: Math-Int64 > Subject: Lost bit on an i386 platform > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: aleksey.mashanov@gmail.com > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=100861 > > > > On an i386: > $ perl -MMath::Int64=int64 -lwe 'print > int64("-2251842763358208")' > > > -42949672960
Hi Aleksey, I am unable to reproduce the issue. Could you describe your environment for the i386 case? which module and perl versions, and which operating system and compiler are you using there? Include also the output for "perl -V".
Чтв Дек 11 12:29:14 2014, sfandino@yahoo.com писал: Show quoted text
> > > > > ----- Original Message -----
> > From: Aleksey Mashanov via RT <bug-Math-Int64@rt.cpan.org> > > To: > > Cc: > > Sent: Thursday, December 11, 2014 4:00 PM > > Subject: [rt.cpan.org #100861] Lost bit on an i386 platform > > > > T hu Dec 11 10:00:41 2014: Request 100861 was acted upon. > > Transaction: Ticket created by amashanov > > Queue: Math-Int64 > > Subject: Lost bit on an i386 platform > > Broken in: (no value) > > Severity: (no value) > > Owner: Nobody > > Requestors: aleksey.mashanov@gmail.com > > Status: new > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=100861 > > > > > > > On an i386: > > $ perl -MMath::Int64=int64 -lwe 'print > > int64("-2251842763358208")' > > > > > > -42949672960
> > > Hi Aleksey, > > I am unable to reproduce the issue. > Could you describe your environment for the i386 case? which module > and perl versions, and which operating system and compiler are you > using there? > > > Include also the output for "perl -V".
We use CentOS 5. It includes perl 5.8.8 with gcc 4.1.2. We use Math::Int64 version 0.29 but I have tried latest version (0.34) and result is the same. $ perl -V Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Platform: osname=linux, osvers=2.6.18-308.24.1.el5xen, archname=i386-linux-thread-multi uname='linux builder17.centos.org 2.6.18-308.24.1.el5xen #1 smp tue dec 4 18:33:26 est 2012 i686 athlon i386 gnulinux ' config_args='-des -Doptimize=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -Dversion=5.8.8 -Dmyhostname=localhost -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux-thread-multi -Dvendorprefix=/usr -Dsiteprefix=/usr -Duseshrplib -Dusethreads -Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio -Dinstallusrbinperl=n -Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less -isr -Dd_gethostent_r_proto -Ud_endhostent_r_proto -Ud_sethostent_r_proto -Ud_endprotoent_r_proto -Ud_setprotoent_r_proto -Ud_endservent_r_proto -Ud_setservent_r_proto -Dinc_version_list=5.8.7 5.8.6 5.8.5 -Dscriptdir=/usr/bin' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef 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='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm', optimize='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables', cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -I/usr/include/gdbm' ccversion='', gccversion='4.1.2 20080704 (Red Hat 4.1.2-54)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='gcc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lresolv -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc perllibs=-lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc libc=/lib/libc-2.5.so, so=so, useshrplib=true, libperl=libperl.so gnulibc_version='2.5' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE' cccdlflags='-fPIC', lddlflags='-shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API Built under linux Compiled at Oct 1 2013 14:19:20 @INC: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .
I have made some investigation into the problem and result is very intresting. As far I understand it affects perl versions before commit 3516f326155ac4c5da84756c2c526e0fa965a37e. sv_bless calls SvUPGRADE(SvRV(sv), SVt_PVMG) which causes in copy of NV structure into PVMG through local variables, including double: nv = SvNVX(sv); This copy is not bit-to-bit stable. If compiler deside to store this local copy in a float-point register then value can be modified to another internal representation. Since this negative int64_t value is mapped into NaN double value it can be safly modified without change of its float-point logic. I have found a workaround for this problem: --- Int64.xs 2014-12-18 21:18:06.000000000 +0300 +++ Int64.xs 2014-12-18 21:17:13.000000000 +0300 @@ -157,7 +157,7 @@ # define BACKEND "NV" # define SvI64Y SvNVX # define SvI64_onY SvNOK_on -# define SVt_I64 SVt_NV +# define SVt_I64 SVt_PVMG #elif defined(INT64_BACKEND_IV) # define BACKEND "IV" # define SvI64Y SvIVX
This issue should now be fixed in version 0.51: https://metacpan.org/release/SALVA/Math-Int64-0.51 Thank you for reporting it!
no feedback and it works for me, so closing!