Click here to get back home

problems with Memoize::Storable

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
problems with Memoize::Storable danielmcbrearty 02-22-2007
Posted by danielmcbrearty on February 22, 2007, 4:54 pm
Please log in for more thread options


hi,

short script to try to use this module:

#!/usr/bin/perl
use strict;
use warnings;

use Memoize qw( memoize unmemoize );
use Memoize::Storable;

tie my %cache => 'Memoize::Storable', 'cache_file';
memoize 'doit', SCALAR_CACHE => [HASH => \%cache];

print "before : \n";
doit();
print "after : \n";

sub doit {
for ( 1 .. 10 ){
unless (exists $cache){
print "adding $_\n";
$cache = "blah $_";
}
}
}

when I run it, I get:
daniel@daniel-ubuntu:~/tmp$ ./memoize_st.pl
before :
adding 1
adding 2
adding 3
adding 4
adding 5
adding 6
adding 7
adding 8
adding 9
adding 10
after :
Segmentation fault

I've checked, both Memoize and Memoize::Storable are up to date.

what could be the issue? any ideas?

thanks, Daniel

PS maybe this helps .. :

daniel@daniel-ubuntu:~/tmp$ perl -V
Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
Platform:
osname=linux, osvers=2.6.15-27-386, archname=i686-linux-thread-
multi
uname='linux daniel-ubuntu 2.6.15-27-386 #1 preempt sat sep 16
01:51:59 utc 2006 i686 gnulinux '
config_args='-d -Dusethreads'
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='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -
fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/
include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-
strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/
include'
ccversion='', gccversion='4.0.3 (Ubuntu 4.0.3-1ubuntu5)',
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 -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -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 -L/usr/local/lib'


Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT
PERL_MALLOC_WRAP THREADS_HAVE_PIDS
USE_ITHREADS
USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API
Built under linux
Compiled at Sep 19 2006 16:22:00
@INC:
/usr/local/lib/perl5/5.8.8/i686-linux-thread-multi
/usr/local/lib/perl5/5.8.8
/usr/local/lib/perl5/site_perl/5.8.8/i686-linux-thread-multi
/usr/local/lib/perl5/site_perl/5.8.8
/usr/local/lib/perl5/site_perl
.


Posted by Mumia W. on February 23, 2007, 12:46 am
Please log in for more thread options


On 02/22/2007 03:54 PM, danielmcbrearty@gmail.com wrote:
> hi,
>
> short script to try to use this module:
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> use Memoize qw( memoize unmemoize );
> use Memoize::Storable;
>
> tie my %cache => 'Memoize::Storable', 'cache_file';
> memoize 'doit', SCALAR_CACHE => [HASH => \%cache];
>
> print "before : \n";
> doit();
> print "after : \n";
>
> sub doit {
> for ( 1 .. 10 ){
> unless (exists $cache){
> print "adding $_\n";
> $cache = "blah $_";
> }
> }
> }
>
> when I run it, I get:
> daniel@daniel-ubuntu:~/tmp$ ./memoize_st.pl
> before :
> adding 1
> adding 2
> adding 3
> adding 4
> adding 5
> adding 6
> adding 7
> adding 8
> adding 9
> adding 10
> after :
> Segmentation fault
>
> I've checked, both Memoize and Memoize::Storable are up to date.
>
> what could be the issue? any ideas?
>
> thanks, Daniel
>

If you fail to "untie %cache;" before the program exits, it segfaults. I
have no idea if this is a bug or not.

My system:
Perl 5.9.4
Debian 3.1 (i386)
Memoize 1.01
Memoize::Storable 0.65


> PS maybe this helps .. :
>
> daniel@daniel-ubuntu:~/tmp$ perl -V
> Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
> Platform:
> osname=linux, osvers=2.6.15-27-386, archname=i686-linux-thread-
> multi
> uname='linux daniel-ubuntu 2.6.15-27-386 #1 preempt sat sep 16
> 01:51:59 utc 2006 i686 gnulinux '
> config_args='-d -Dusethreads'
> 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='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -
> fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/
> include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
> optimize='-O2',
> cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-
> strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/
> include'
> ccversion='', gccversion='4.0.3 (Ubuntu 4.0.3-1ubuntu5)',
> 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 -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
> perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -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 -L/usr/local/lib'
>
>
> Characteristics of this binary (from libperl):
> Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT
> PERL_MALLOC_WRAP THREADS_HAVE_PIDS
> USE_ITHREADS
> USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API
> Built under linux
> Compiled at Sep 19 2006 16:22:00
> @INC:
> /usr/local/lib/perl5/5.8.8/i686-linux-thread-multi
> /usr/local/lib/perl5/5.8.8
> /usr/local/lib/perl5/site_perl/5.8.8/i686-linux-thread-multi
> /usr/local/lib/perl5/site_perl/5.8.8
> /usr/local/lib/perl5/site_perl
> .
>

--
Windows Vista and your freedom in conflict:
http://www.badvista.org/

Posted by danielmcbrearty on February 23, 2007, 6:03 am
Please log in for more thread options


Indeed, that seems to cure. I can't figure out quite why this is
either. I'll mail MJD and ask. A core dump does seem a bit extreme.

thanks for the help.

On 23 Feb, 06:46, "Mumia W." <paduille.4060.mumia.w
+nos...@earthlink.net> wrote:
> On 02/22/2007 03:54 PM, danielmcbrea...@gmail.com wrote:
>
>
>
> > hi,
>
> > short script to try to use this module:
>
> > #!/usr/bin/perl
> > use strict;
> > use warnings;
>
> > use Memoize qw( memoize unmemoize );
> > use Memoize::Storable;
>
> > tie my %cache => 'Memoize::Storable', 'cache_file';
> > memoize 'doit', SCALAR_CACHE => [HASH => \%cache];
>
> > print "before : \n";
> > doit();
> > print "after : \n";
>
> > sub doit {
> > for ( 1 .. 10 ){
> > unless (exists $cache){
> > print "adding $_\n";
> > $cache = "blah $_";
> > }
> > }
> > }
>
> > when I run it, I get:
> > daniel@daniel-ubuntu:~/tmp$ ./memoize_st.pl
> > before :
> > adding 1
> > adding 2
> > adding 3
> > adding 4
> > adding 5
> > adding 6
> > adding 7
> > adding 8
> > adding 9
> > adding 10
> > after :
> > Segmentation fault
>
> > I've checked, both Memoize and Memoize::Storable are up to date.
>
> > what could be the issue? any ideas?
>
> > thanks, Daniel
>
> If you fail to "untie %cache;" before the program exits, it segfaults. I
> have no idea if this is a bug or not.
>
> My system:
> Perl 5.9.4
> Debian 3.1 (i386)
> Memoize 1.01
> Memoize::Storable 0.65
>
>
>
> > PS maybe this helps .. :
>
> > daniel@daniel-ubuntu:~/tmp$ perl -V
> > Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
> > Platform:
> > osname=linux, osvers=2.6.15-27-386, archname=i686-linux-thread-
> > multi
> > uname='linux daniel-ubuntu 2.6.15-27-386 #1 preempt sat sep 16
> > 01:51:59 utc 2006 i686 gnulinux '
> > config_args='-d -Dusethreads'
> > 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='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -
> > fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/
> > include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
> > optimize='-O2',
> > cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-
> > strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/
> > include'
> > ccversion='', gccversion='4.0.3 (Ubuntu 4.0.3-1ubuntu5)',
> > 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 -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
> > perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -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 -L/usr/local/lib'
>
> > Characteristics of this binary (from libperl):
> > Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT
> > PERL_MALLOC_WRAP THREADS_HAVE_PIDS
> > USE_ITHREADS
> > USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API
> > Built under linux
> > Compiled at Sep 19 2006 16:22:00
> > @INC:
> > /usr/local/lib/perl5/5.8.8/i686-linux-thread-multi
> > /usr/local/lib/perl5/5.8.8
> > /usr/local/lib/perl5/site_perl/5.8.8/i686-linux-thread-multi
> > /usr/local/lib/perl5/site_perl/5.8.8
> > /usr/local/lib/perl5/site_perl
> > .
>
> --
> Windows Vista and your freedom in conflict:http://www.badvista.org/



Similar ThreadsPosted
Accessing the Memoize cache April 2, 2005, 1:15 am
manually expire an element in Memoize (also on comp.lang.perl.misc) February 14, 2007, 5:52 pm
Storable - Perl Mod September 20, 2004, 6:11 am
Problem with Storable on Windows July 4, 2005, 9:20 pm
Downgrade storable under Perl 5.8 August 6, 2006, 11:16 pm
Bit::Vector objects serialized with Storable not working September 13, 2004, 3:15 am
Trouble installing storable 2.13 with perl 5.8.0 on redhat 9 machine December 10, 2004, 12:06 am
Problems using GD.pm January 8, 2005, 8:05 pm
Problems when using Net::MSN 1.022 May 4, 2005, 1:20 pm
LWP problems July 11, 2005, 3:50 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap