Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the YAML CPAN distribution.

Report information
The Basics
Id: 29113
Status: resolved
Priority: 0/
Queue: YAML

People
Owner: ingy [...] cpan.org
Requestors: rafl [...] debian.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 0.65
  • 0.63
  • 0.64
Fixed in: 1.24



Subject: Inline !!perl/code broken
The following code, which tries to Load() a serialized coderef fails: perl -MExtUtils::testlib -MYAML -e'$YAML::LoadCode = 1; $c = YAML::Load(<<EOY); --- !!perl/code "{ print q{foo} }" EOY' resulting in the following error message: Illegal character in prototype for main::CODE : 0x83f7bd8 at (eval 33) line 1. stack trace: Illegal character in prototype for main::CODE : 0x83dd4d8 at (eval 33) line 1 eval 'package main; sub CODE(0x83dd4d8) ;' called at /home/rafl/.perl/share/perl5/YAML/Types.pm line 149 YAML::Type::code::yaml_load('YAML::Type::code', 'CODE(0x83dd4d8)', '', 'YAML::Loader=HASH(0x80bd4d4)') called at /home/rafl/.perl/share/perl5/YAML/Loader.pm line 281 YAML::Loader::_parse_explicit('YAML::Loader=HASH(0x80bd4d4)', 'CODE(0x83dd4d8)', '!perl/code') called at /home/rafl/.perl/share/perl5/YAML/Loader.pm line 195 YAML::Loader::_parse_node('YAML::Loader=HASH(0x80bd4d4)') called at /home/rafl/.perl/share/perl5/YAML/Loader.pm line 100 YAML::Loader::_parse('YAML::Loader=HASH(0x80bd4d4)') called at /home/rafl/.perl/share/perl5/YAML/Loader.pm line 22 YAML::Loader::load('YAML::Loader=HASH(0x80bd4d4)', '--- !!perl/code "{ print q{foo} }"\x{a}') called at /home/rafl/.perl/share/perl5/YAML.pm line 33 YAML::Load('--- !!perl/code "{ print q{foo} }"\x{a}') called at -e line 2 eval "package main; sub CODE(0xaddr);" seems to indicate that you're trying to turn the string containing the code into a coderef twice. Some debugging showed that this is indeed the case: _parse_node calls _parse_inline, which in turn calls _parse_explicit, which does the first eval and assigns the returned coderef to the current $node. Later on _parse_node calls _parse_explict again which then fails as eval "package main; sub $node" stringifies node, which is a coderef already, and leads to broken perl code and the above error. The following form works nevertheless: -- !!perl/code | { print q{foo} }
FWIW, this seems to be broken since 0.63. 0.62 did at least not complain.
This issue has been copied to: https://github.com/ingydotnet/yaml-pm/issues/83 please take all future correspondence there. This ticket will remain open but please do not reply here. This ticket will be closed when the github issue is dealt with.
fixed in 1.24