develooper Front page | perl.perl5.porters | Postings from February 2006

[perl #38416] 5.8.0 pure-perl program dumps core

Thread Next
From:
Mark-Jason Dominus
Date:
February 2, 2006 22:40
Subject:
[perl #38416] 5.8.0 pure-perl program dumps core
Message ID:
rt-3.0.11-38416-129388.11.3638171412445@perl.org
# New Ticket Created by  Mark-Jason Dominus 
# Please include the string:  [perl #38416]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=38416 >



This is a bug report for perl from mjd@plover.com,
generated with the help of perlbug 1.34 running under perl v5.8.0.


-----------------------------------------------------------------
[Please enter your report here]

I don't have anything more recent than 5.8.0 to try this with.  Can
someone please check to see if it segfaults with a more recent version
than that?


        use Memoize;
        my @primes = ();

        memoize 'is_prime';
        for my $A (0..3) {
            for my $B (0..3) {
                print "$A + $ {B}i is prime\n" if is_prime($A, $B);
            }
        }

        sub is_prime {
            my ($a, $b) = @_;
            my $norm = norm(@_);
            return 0 if $norm < 2;
            for my $n (2 .. $norm-1) {
                calculate_all_primes($n);
                return 0 if divides_any([$a, $b], $primes[$n]);
            }
            push @{$primes[$norm]}, [$a, $b];
            return 1;
        }

        sub calculate_all_primes {
            my $n = shift;
            for my $a (0 .. $n) {
                my $b = sqrt($n * $n - $a * $a);
                next unless $b == int($b);
                is_prime($a, $b);
            }
        }

        sub divides_any {
            my ($p, $qs) = @_;
            for my $q (@$qs) {
                return 1 if divides($q, $p);
            }
            return 0;
        }

        sub divides {
            my ($p, $q) = @_;
            my ($a, $b, $c, $d) = (@$p, @$q);
            my $n = norm($c, $d);
            ($a*$c+$b*$d) % $n == 0 &&
            ($b*$c-$a*$d) % $n == 0;
        }

        sub norm {
            my ($a, $b) = @_;
            $a*$a + $b*$b;
        }


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=high
---
Site configuration information for perl v5.8.0:

Configured by mjd at Thu Apr 17 11:57:37 EDT 2003.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.4.2-2, archname=i586-linux
    uname='linux plover.com 2.4.2-2 #1 sun apr 8 19:37:14 edt 2001 i586 unknown '
    config_args='-des'
    hint=previous, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef 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='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-O2',
    cppflags='-fno-strict-aliasing -I/usr/local/include -I/usr/include/gdbm -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm'
    ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.1 2.96-81)', 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='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldl -lm -lc -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
    libc=/lib/libc-2.2.2.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.2.4'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl v5.8.0:
    /usr/local/lib/perl5/5.8.0/i586-linux
    /usr/local/lib/perl5/5.8.0
    /usr/local/lib/perl5/site_perl/5.8.0/i586-linux
    /usr/local/lib/perl5/site_perl/5.8.0
    /usr/local/lib/perl5/site_perl/5.7.3
    /usr/local/lib/perl5/site_perl/5.7.2
    /usr/local/lib/perl5/site_perl/5.6.1
    /usr/local/lib/perl5/site_perl/5.6.0
    /usr/local/lib/perl5/site_perl
    .

---
Environment for perl v5.8.0:
    HOME=/home/mjd
    LANG=C
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/lib:/usr/lib:/usr/X11R6/lib
    LOGDIR (unset)
    PATH=/home/mjd/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/games:/sbin:/usr/sbin:/usr/local/bin/X11R6:/usr/local/bin/mh:/data/mysql/bin:/usr/local/bin/pbm:/usr/local/bin/ezmlm:/home/mjd/TPI/bin:/usr/local/teTeX/bin:/usr/local/mysql/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About