Skip Menu |

This queue is for tickets about the Config-YAML CPAN distribution.

Report information
The Basics
Id: 11886
Status: resolved
Priority: 0/
Queue: Config-YAML

People
Owner: mdxi [...] cpan.org
Requestors: JFITZ [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.37
Fixed in: 1.40



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.
Download YAML.pm.diff.gz
application/x-cpio 313b

Message body not shown because it is not plain text.

I've confirmed the problem, which also happens under perl 5.8.4 (my current version). I want to find out *why* this happens, but if I can't do that by later tonight I'll apply your diff and push out a new version so you won't be inconvenienced any longer than neccessary.
The problem appears to have been my syntax on the hash slice. Instead of: @{%{$self}}{keys %args} = values %args; the correct syntax is the slightly less obfuscated: @{$self}{keys %args} = values %args; This passes all dist tests as well as the submitted test case. I've rolled a new release (1.40) and uploaded it to PAUSE. Please follow-up with your results. Thanks.
[MDXI - Tue Mar 15 17:52:40 2005]: Show quoted text
> This passes all dist tests as well as the submitted test case. I've > rolled a new release (1.40) and uploaded it to PAUSE. Please follow-up > with your results. Thanks.
v1.40 works just fine for me in situations where 1.37 would break. Thanks very much for the quick follow-up. -- j.
Realized late last night that fold() contained the same error. C::Y 1.41 is now in PAUSE. The only changes in it are the fix to fold() and a new entry in the "Changes" file. Will close this ticket at EOB if no ill effects are reported.