Skip Menu |

This queue is for tickets about the DBD-SQLite2 CPAN distribution.

Report information
The Basics
Id: 28448
Status: resolved
Priority: 0/
Queue: DBD-SQLite2

People
Owner: Nobody in particular
Requestors: Thomas.Skora [...] secunet.com
Cc:
AdminCc:

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



Subject: Overflow when user defined function returns values >= 2^31
Date: Tue, 24 Jul 2007 12:19:40 +0200
To: <bug-DBD-SQLite2 [...] rt.cpan.org>
From: "Skora, Thomas" <Thomas.Skora [...] secunet.com>
Here the information about the system where this problem was reproduced: ---------------------- Show quoted text
cpan> i DBD::SQLite2
CPAN: Storable loaded ok Going to read /cpan/Metadata Database was generated on Mon, 23 Jul 2007 03:51:52 GMT Strange distribution name [DBD::SQLite2] Module id = DBD::SQLite2 CPAN_USERID MSERGEANT (MSERGEANT <msergeant@cpan.org>) CPAN_VERSION 0.33 CPAN_FILE M/MS/MSERGEANT/DBD-SQLite2-0.33.tar.gz MANPAGE DBD::SQLite2 - Self Contained RDBMS in a DBI Driver (sqlite 2.x) INST_FILE /usr/lib/perl5/site_perl/5.8/cygwin/DBD/SQLite2.pm INST_VERSION 0.33 $ perl -v This is perl, v5.8.7 built for cygwin-thread-multi-64int (with 1 registered patch, see perl -V for more detail) Copyright 1987-2005, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using `man perl' or `perldoc perl'. If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page. $ perl -V Summary of my perl5 (revision 5 version 8 subversion 7) configuration: Platform: osname=cygwin, osvers=1.5.18(0.13242), archname=cygwin-thread-multi-64int uname='cygwin_nt-5.1 inspiron 1.5.18(0.13242) 2005-07-02 20:30 i686 unknown unknown cygwin ' config_args='-de -Dmksymlinks -Duse64bitint -Dusethreads -Uusemymalloc -Doptimize=-O3 -Dman3ext=3pm -Dusesitecustomize' 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=define use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags ='-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -pipe -I/usr/local/include', optimize='-O3', cppflags='-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -pipe -I/usr/local/include' ccversion='', gccversion='3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='ld2', ldflags =' -s -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lgdbm -ldb -lcrypt -lgdbm_compat perllibs=-lcrypt -lgdbm_compat libc=/usr/lib/libc.a, so=dll, useshrplib=true, libperl=libperl.a gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' -s' cccdlflags=' ', lddlflags=' -s -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY USE_ITHREADS USE_64_BIT_INT USE_LARGE_FILES USE_SITECUSTOMIZE PERL_IMPLICIT_CONTEXT Locally applied patches: SPRINTF0 - fixes for sprintf formatting issues - CVE-2005-3962 Built under cygwin Compiled at Dec 30 2005 02:44:25 %ENV: CYGWIN="" @INC: /usr/lib/perl5/5.8/cygwin /usr/lib/perl5/5.8 /usr/lib/perl5/site_perl/5.8/cygwin /usr/lib/perl5/site_perl/5.8 /usr/lib/perl5/site_perl/5.8/cygwin /usr/lib/perl5/site_perl/5.8 /usr/lib/perl5/vendor_perl/5.8/cygwin /usr/lib/perl5/vendor_perl/5.8 /usr/lib/perl5/vendor_perl/5.8/cygwin /usr/lib/perl5/vendor_perl/5.8 . $ uname -a CYGWIN_NT-5.1 SN-E0490 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygwin ---------------------- The same problem occurs also on a Linux box with perl 5.8.8 and the same DBD::SQLite2 version. A code Piece which reproduces this bug: --------------------- #!/usr/bin/perl use DBI; sub return_big { return 2**32; } my $dbh = DBI->connect("dbi:SQLite2:dbname=foo", "", "", { PrintError => 0 } ); $dbh->func( "bignumber", 0, \&return_big, "create_function" ); my $result = $dbh->selectrow_arrayref( "SELECT bignumber()" ); print $$result[0]; ---------------------
Not repro with 32bit, 64bit and mixed use64bitint perls. I added a testcase to t/08create_function.t though. See https://github.com/rurban/DBD-SQLite2 2**32 always returns the correct positive number 4294967296 stringified DB x Dump($result) SV = PVMG(0x938e9e0) at 0x9165944 REFCNT = 2 FLAGS = (PADMY,ROK) IV = 0 NV = 0 RV = 0x937e55c SV = PVAV(0x92f7180) at 0x937e55c REFCNT = 1 FLAGS = (READONLY) ARRAY = 0x939be30 FILL = 0 MAX = 3 ARYLEN = 0x0 FLAGS = (REAL) Elt No. 0 SV = PV(0x93538b8) at 0x937e444 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x939ae10 "4294967296"\0 CUR = 10 LEN = 12 PV = 0x937e55c "" CUR = 0 LEN = 0 empty array -- Reini Urban
Added testcase, not repro. Please provide the output you think is wrong when you want to reopen the ticket. -- Reini Urban
I can now reproduce it and it's easy to see why in the source code. sqlite itself cannot handle result types of long, only int or double. This is independent of 64bitint or 32bit. So we need to promote to double on results >I32_MAX. This is fixed with 0.37. But somehow this still fails on all perl versions < 5.8.9. -- Reini Urban
On Tue Dec 08 08:54:24 2015, RURBAN wrote: Show quoted text
> I can now reproduce it and it's easy to see why in the source code. > sqlite itself cannot handle result types of long, only int or double. > This is independent of 64bitint or 32bit. > > So we need to promote to double on results >I32_MAX. This is fixed > with 0.37. > But somehow this still fails on all perl versions < 5.8.9.
Found and fixed the problem with 0.37 -- Reini Urban