CC: | Richard <vzshzn [...] gmail.com> |
Subject: | Re: MBI segfault |
Date: | Thu, 17 Apr 2008 20:35:17 +0200 |
To: | bug-Math-BigInt-FastCalc [...] rt.cpan.org |
From: | "Zsbán Ambrus" <ambrus [...] math.bme.hu> |
Hi,
The following command causes a segmentation fault on my perl 5.10.0 on
i686 linux:
perl -wE 'use Math::BigRat "lib", "FastCalc"; use Math::BigFloat
"lib", "FastCalc"; say
Math::BigFloat->as_number(Math::BigRat->new("10/7"));'
This code is clearly wrong: the as_number method is called with
parameters I shouldn't give to it. However, I believe it still
shoudn't result in a segfault, but either die or give some result.
This is especially true because FastCalc is now the default engine for
MBI.
At least two other people have confirmed that this command segfaults
on their machine too.
I couldn't reproduce the bug with perl 5.8.8.
Zshzn has kindly volunteered to look in this segfault with a debugger.
He says the following.
On Wed, Apr 16, 2008 at 10:52 PM, Richard <vzshzn@gmail.com> wrote:
Show quoted text
> Here's what I've found out about your
> segfault:
>
> It happens in _copy of FastCalc.xs, which is called from BigFloat.pm's
> as_number at about line 3642.
>
> as_number tries to _copy $x->{_m}, which is undef. I assume the undefness of
> the situation causes the problem :p
>
> I would get more accurate info but by recompiling FastCalc the problem went
> away. Maybe it has already been fixed, at least on one end.
Here are some details about my installation.
[am]king ~/a/tmp$ perl -wE 'use Math::BigRat "lib", "FastCalc"; use
Math::BigFloat "lib", "FastCalc"; say
Math::BigFloat->as_number(Math::BigRat->new("10/7"));'
Segmentation fault
139[am]king ~/a/tmp$ perl -V
Summary of my perl5 (revision 5 version 10 subversion 0) configuration:
Platform:
osname=linux, osvers=2.6.20.6, archname=i686-linux
uname='linux king 2.6.20.6 #3 smp tue may 29 09:42:52 cest 2007
i686 gnulinux '
config_args=''
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-fno-strict-aliasing -pipe
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-fno-strict-aliasing -pipe -I/usr/local/include'
ccversion='', gccversion='4.1.1', 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 /usr/lib64
libs=-lnsl -ldl -lm -lcrypt -lutil -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.3.6.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.3.6'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP
USE_LARGE_FILES USE_PERLIO
Built under linux
Compiled at Dec 18 2007 19:48:06
@INC:
/usr/local/lib/perl5/5.10.0/i686-linux
/usr/local/lib/perl5/5.10.0
/usr/local/lib/perl5/site_perl/5.10.0/i686-linux
/usr/local/lib/perl5/site_perl/5.10.0
/usr/local/lib/perl5/site_perl/5.8.8
/usr/local/lib/perl5/site_perl
.
[am]king ~/a/tmp$ perl -wE 'use Math::BigInt; say
$Math::BigInt::VERSION;' # this is the version that comes with perl
5.10.0
1.88
[am]king ~/a/tmp$ perl -wE 'use Math::BigRat; say
$Math::BigRat::VERSION;' # this one is updated though
0.22
[am]king ~/a/tmp$ perl -wE 'use Math::BigInt::FastCalc; say
$Math::BigInt::FastCalc::VERSION;'
0.19
Incidentally, thanks for the new as_float method in Math::BigRat, it's
just what I'd have needed for a program I wrote two months ago.
Ambrus