Subject: | bad destroy behavior |
There is an issue with DESTROY in the Bloom::Faster. I noticed two behaviors.
The first behavior is that creating multiple bloom filters with the same parameters, one after the other after
destroy on the previous is called results in a core dump.
The second behavior is that, when in a loop and DESTROY is implicitly called, the new bloom filter can retain the
same vector as the previous one. A newly created filter shouldn't return true for anything and certainly not consistantly.
Here are two simple programs that demonstrate this effect.
This is for version 1.7, the current version as of the writing of this.
Module id = Bloom::Faster
CPAN_USERID PALVARO (Peter Alvaro <palvaro@cpan.org>)
CPAN_VERSION 1.7
CPAN_FILE P/PA/PALVARO/Bloom-Faster-1.7.tar.gz
MANPAGE Bloom::Faster - Perl extension for the c library libbloom.
INST_FILE /usr/local/lib/x86_64-linux-gnu/perl/5.26.0/Bloom/Faster.pm
INST_VERSION 1.7
# ------------ PROGRAM 1 ---------------------
use strict;
use Bloom::Faster;
my $str = "FOOZER";
my $filter = new Bloom::Faster( { n=> 500_000, e => 0.001 } );
print "1";
if( $filter->check( $str ) ) {
print " NOES";
}
print "\n";
$filter->add( $str );
$filter->DESTROY;
$filter = new Bloom::Faster( { n=> 500_000, e => 0.001 } );
print "2";
if( $filter->check( $str ) ) {
print " NOES";
}
print "\n";
$filter->add( $str );
$filter->DESTROY;
print "3";
$filter = new Bloom::Faster( { n=> 500_000, e => 0.001 } );
if( $filter->check( $str ) ) {
print " NOES";
}
print "\n";
$filter->add( $str );
$filter->DESTROY;
# ------------ OUTPUT 1 ---------------------
perl bin/gah.pl
1
2
Bus error (core dumped)
# ------------ PROGRAM 2 ---------------------
use strict;
use Bloom::Faster;
my $str = "FOOZER";
for( 1..10 ) {
print "$_";
my $filter1 = new Bloom::Faster( { n=> 500_000, e => 0.001 } );
print "\n";
}
# ------------ OUTPUT 2 ---------------------
perl bin/gah2.pl
1
2
3 NOES
4 NOES
5 NOES
6 NOES
7 NOES
8 NOES
9 NOES
10 NOES