Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

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

Report information
The Basics
Id: 33717
Status: resolved
Priority: 0/
Queue: YAML-LibYAML

People
Owner: Nobody in particular
Requestors: brbpub [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: "Modification of non-creatable hash value attempted"
Date: Fri, 29 Feb 2008 15:17:50 -0500
To: bug-YAML-LibYAML [...] rt.cpan.org
From: Bernardo Rechea <brbpub [...] gmail.com>
When Load'ing a YAML hash with a key whose value is undef, YAML::XS errors with subject line message. YAML and YAML::Syck work. The code below reproduces the problem. ============================= #!/usr/bin/env perl use 5.10.0; use YAML::XS qw(Dump Load); # This errors #use YAML qw(Dump Load); # This works #use YAML::Syck qw(Dump Load); # This works my $d = Load(<<EOY); a: 2 b: - 3 - asdf c: ~ EOY # Attempt to change the undef to a string blows up when using YAML::XS $d->{c} = 'kk'; say Dump($d); ============================= Interestingly, when the hash is dereferenced, it works: ============================= #!/usr/bin/env perl use 5.10.0; use YAML::XS qw(Dump Load); # This errors #use YAML qw(Dump Load); # This works #use YAML::Syck qw(Dump Load); # This works my %d = %{ Load(<<EOY) }; a: 2 b: - 3 - asdf c: ~ EOY $d{c} = 'kk'; say Dump(\%d); =============================
The issue is that the special SV values &PL_sv_undef, &PL_sv_yes and &PL_sv_no are not really allowed to be values in hashes or arrays. The same problem occur if you store 'true' or 'false' as a value or if you store these values in an array. A possible fix (for the hash case only) is: Index: main/Camel/src/cpan/Y/YAML/YAML-LibYAML/main/LibYAML/perl_libyaml.c --- main/Camel/src/cpan/Y/YAML/YAML-LibYAML/main/LibYAML/perl_libyaml.c.~1~ Tue May 13 22:28:55 2008 +++ main/Camel/src/cpan/Y/YAML/YAML-LibYAML/main/LibYAML/perl_libyaml.c Tue May 13 22:28:55 2008 @@ -250,6 +250,11 @@ while ((key_node = load_node(loader))) { assert(SvPOK(key_node)); value_node = load_node(loader); + if (SvREADONLY(value_node)) { + SV* tmp = newSVsv(value_node); + SvREFCNT_dec(value_node); + value_node = tmp; + } hv_store( hash, SvPV_nolen(key_node), sv_len(key_node), value_node, 0 ); End of Patch. but this breaks the t/boolean.t test that wan't to ensure that true/false roundtrip. I think the boolean roundtrip need to loose.
It seems this has been fixed at some point (for undef values). Closing.