Subject: | Sync in the destroy |
In the Tie::Persistent modules, a sync is linked to the DESTROY
function, same if the automatic sync is disabled:
*DESTROY = \&sync; # make an alias
This creates issues if I store some regular expression in a tied file.
During the DESTROY call from PERL, the regular expression are removed.
Here is the script which reproduce the issue (this happens only when my
Tie variable is a global variable of my object):
bash$ cat t.pl
#!/usr/bin/perl -w
package TestTie;
use Tie::Persistent;
my %t;
sub new {
$Tie::Persistent::Readable = 1;
tie %t, 'Tie::Persistent', '/tmp/ttttt', 'rw';
(tied %t)->autosync(0);
$t{yy} = qr/^(\S+)\S+myregex$/;
(tied %t)->sync();
bless {hash => \%t}, 'TestTie';
}
package main;
my $yy = TestTie->new();
use Data::Dumper;
print Dumper($yy);
bash$ ./t.pl
$VAR1 = bless( {
'hash' => {
'yy' => qr/(?-xism:^(\S+)\S+myregex$)/
}
}, 'TestTie' );
bash$ cat /tmp/ttttt
$PersistentData = {
'yy' => undef
};
By executing the following commands, it is possible to see that the
regular expressions are destroyed before the sync:
PERLDB_OPTS="NonStop=1 AutoTrace=1 frame=2" perl -dS ./t.pl
....
entering Regexp::DESTROY
exited Regexp::DESTROY
entering Storable::Cxt::DESTROY
exited Storable::Cxt::DESTROY
entering Config::DESTROY
1266: sub DESTROY { }
exited Config::DESTROY
entering Tie::Persistent::sync
....
PERL version:
$ perl -v
This is perl, v5.8.2 built for sun4-solaris-thread-multi
OS :
$ uname -a
SunOS goupil 5.8 Generic_117350-04 sun4u sparc SUNW,UltraAX-i2
(As also been tested on Centos)