Subject: | Hash slices blow up the debugger with C::Y 1.37 & perl 5.8.6 |
Given this code:
--START--
use Config::YAML;
my $cfg = Config::YAML->new( config => 'foo.yaml' );
---END---
And this config file:
--START--
--- #YAML: 1.0
foo: bar
---END---
Running the script in the debugger with Config::YAML v1.37 and perl v5.8.6 explodes mightily:
--START--
[hades:jfitz] ~...mail/lyris/trunk (289) > perl -d foo.pl
Loading DB routines from perl5db.pl version 1.28
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(foo.pl:2): my $cfg = Config::YAML->new( config => 'foo.yaml' );
DB<1> n
Bizarre copy of HASH in leave at /opt/perl5/lib/site_perl/5.8.6/Config/YAML.pm line 110.
at /opt/perl5/lib/site_perl/5.8.6/Config/YAML.pm line 110
Config::YAML::new('Config::YAML', 'config', 'foo.yaml') called at foo.pl line 2
Debugged program terminated. Use q to quit or R to restart,
use O inhibit_exit to avoid stopping after program termination,
h q, h R or h O to get additional info.
DB<1> q
[hades:jfitz] ~...mail/lyris/trunk (290) >
---END---
I've tracked this down to the hash slice majick you're doing in new() and read(), though I am at a loss to explain why it happens. I have been able to get around the problem by rewriting the hash slice line to be a foreach loop over the keys of the source hash (patch attached). Surprisingly, it's not that much slower:
1.37:
timethis for 60: 64 wallclock secs (63.76 usr + 0.10 sys = 63.86 CPU) @ 56.64/s (n=3617)
patched:
timethis for 60: 63 wallclock secs (63.14 usr + 0.15 sys = 63.29 CPU) @ 54.91/s (n=3475)
I've been sidestepping the bug in non-patched copies of the module by using YAML::LoadFile() instead of Config::YAML->new() when in development and switching to C::Y once I'm ready to deploy. The problem is that this approach denies me the additional methods of C::Y and forces me to remove blank lines and comments that C::Y strips before calling YAML::Load(), so it's not a very nice workaround.
Thanks for any insight you might have.
Message body not shown because it is not plain text.