Package: libyaml-perl Version: 0.39-1 Severity: important Hi.
You'll find here attached 3 files providing a stripped-down version of a program that uncovered some strange behaviour of the YAML module when using the "load" method. In "TY.pm", when using the "Load" function (commented out line), the behaviour is as expected, but not so with "load" for which the script produces: ---CUT--- The input is correctly read from file, as you can see: --- !perl/TY key: some value Something wrong happens in the "load" OO method: Use of uninitialized value in substitution (s///) at /usr/share/perl5/YAML.pm line 670. Use of uninitialized value in substitution (s///) at /usr/share/perl5/YAML.pm line 671. Use of uninitialized value in pattern match (m//) at /usr/share/perl5/YAML.pm line 673. Use of uninitialized value in length at /usr/share/perl5/YAML.pm line 675. Use of uninitialized value in split at /usr/share/perl5/YAML.pm line 678. And the "dump" shows that the input was not correctly loaded: --- !perl/TY key: ~ ---CUT--- In the full program I was working on, the side-effect was even stranger: I didn't get any of the above error messages from inside YAML.pm *but* on return from the "load" method, my variable didn't contain the unserialized "TY" object but the enclosing data (the equivalent of "$config" in the script provided here)! [Obviously that doesn't happen with the reduced script, but why, I don't know...] Regards, Gilles -- System Information: Debian Release: testing/unstable APT prefers unstable APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable') Architecture: amd64 (x86_64) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.14-vs2.1.0-rc5+g3 Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) Versions of packages libyaml-perl depends on: ii perl 5.8.7-7 Larry Wall's Practical Extraction libyaml-perl recommends no packages. -- no debconf information
package TY ; use strict ; use YAML ; sub load { my $proto = shift ; my $input = shift ; my $class = ref( $proto ) || $proto ; print 'The input is correctly read from file, as you can see:', "\n\n", $input, "\n" ; print 'Something wrong happens in the "load" OO method:', "\n" ; my $self = YAML->new->load( $input ) ; # my $self = Load( $input ) ; return __PACKAGE__->new( $self->{'key'} ) ; } sub new { my $proto = shift ; my $class = ref( $proto ) || $proto ; my $arg = shift ; my $self = { key => $arg } ; bless( $self, $class ) ; return $self ; } sub dump { my $self = shift ; return YAML->new->dump( $self ) ; } 1 ;
--- !perl/TY key: some value
#!/usr/bin/perl -w use strict ; use TY ; use IO::File ; my $config = { 'input' => [ { 'ty' => 'ty.yaml' } ] } ; my @input = @{$config->{'input'}} ; for ( my $i = 0 ; $i < @input ; $i++ ) { my $ty = TY->load( join( '', &readTY( $input[$i]->{'ty'} ) ) ) ; print 'And the "dump" shows that the input was not correctly loaded:', "\n\n", $ty->dump, "\n" ; } sub readTY { my $file = shift ; my $io = IO::File->new( $file, "r" ) ; my @text = $io->getlines ; $io->close ; return @text ; }