Good Day Fair Monks,

I am using Storable and every so often it all goes pear shaped.

Magic number checking on storable file failed at /usr/localperl/lib/5.18.2/x86_64-linux-thread-multi/Storable.pm line 380 ...

My code runs every five minutes, and will happily store about 5 samples, then it throws the above and dumps core. The store file is zero bytes after that event. When things are good I see these details.

> file itm6_linux_server.memstore > itm6_linux_server.memstore: perl Storable (v0.7) data (major 2) (min +or 9) # from print Dumper Storable::file_magic 'hdrsize' => 19, 'ptrsize' => 8, 'byteorder' => '12345678', 'intsize' => 4, 'file' => 'itm6_linux_server.memstore', 'longsize' => 8, 'netorder' => 0, 'minor' => 9, 'version_nv' => '2.009', 'major' => 2, 'nvsize' => 8, 'version' => '2.9' > ls -l itm6_linux_server.memstore -rw-rw-rw- 1 root root 2514 May 1 16:25 itm6_linux_server.memstore >perl -v This is perl 5, version 18, subversion 2 (v5.18.2) built for x86_64-li +nux-thread-multi

The amount of data is not massive, It currently has 5 records in there, and is 2026 Bytes. The Data I am storing is a hash/array structure, 5 levels at its deepest.

I'm using lock_store and lock_retrieve to get at it, as the script runs on a schedule, as well as me running it every so often for development and debug. The script uses a file lock to guard against multiple runs anyway. I just added the lock_ versions when I hit this error. Did not help. It is only being accessed on the one machine, with the one version of Perl

Any ideas what could be wrong. The code is long and complex. So building a small test case will be a rather long winded process. If there are any known gotchas with Storable I would love a pointer.

Update

All the code is massive. But here are my retrieve and store routines

sub getMem { my $self = shift; my $confID = shift; $confID = $self->{_itm6_lib_gen}->{_CONFID} unless defined $confID +; my $mem = {}; # default to an empty one my $local_store = "local_$confID.memstore"; if (-e $local_store) { eval { $mem = lock_retrieve $local_store }; if ($@) { $self->{_logger}->trace( 1, "getMem: Reading store failed: + $@"); print "getMem: Reading store failed: $@\n"; } } else { # print "$local_store not found\n"; } push @{ $self->{_file_to_write} }, [$mem, $local_store]; # note we + need to write this return $mem; } # Saving is done in DESTROY sub DESTROY { my $self = shift; for (@{ $self->{_file_to_write} }) { my ($mem, $store) = @$_; lock_store ($mem, $store); } }

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!

In reply to Storable dumping core by Random_Walk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.