Subject: | $Storable::accept_future_minor default value doesn't take effect until second retrieval |
$Storable::accept_future_minor is supposed to default to 1, but on the
first call to retrieve, the code behaves as if it is 0.
Walking through Storable.xs, I figured out why.
In Storable.xs, magic_check fetches $Storable::accept_future_minor and
stores it in ctxt->accept_future_minor if the latter was set to -1.
init_retrieve_context initializes it to that value. Unfortunately,
do_retrieve calls magic_check before it calls init_retrieve_context, so
at that point, ctxt->accept_future_minor is still 0.
A work-around for this bug is to retrieve a dummy file before the first
attempt to retrieve a file which might have a future minor version, like so:
BEGIN {
Storable::thaw(Storable::nfreeze({}));
};
This will cause init_retrieve_context to get called, so that later when
the future-versioned file is retrieved, ctxt->accept_future_minor is -1,
and the code behaves as intended.
A fix would be to initialize ctxt->accept_future_minor to -1 earlier,
right before the call to magic_check on line 6119 of Storable.xs.
I first found this bug in Storable-2.13, trying to read a file created
by Storable-2.15, but I've confirmed that code is the same in 2.18 as
well, so the next time the format minor version is bumped, this will
bite people again.
I found the problem with Perl-5.8.6 and Perl-5.8.8, but I don't think
it's dependent on the version of Perl. "uname -a" is probably similarly
irrelevant, but here it is just in case:
Linux jleader.sys.corp.oversee.net 2.6.18-53.1.21.el5 #1 SMP Tue May 20
09:34:18 EDT 2008 i686 i686 i386 GNU/Linux