Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storable hooks silently convert '' to undef #13041

Closed
p5pRT opened this issue Jun 20, 2013 · 6 comments

Comments

@p5pRT
Copy link
Collaborator

@p5pRT p5pRT commented Jun 20, 2013

Migrated from rt.perl.org#118551 (status was 'resolved')

Searchable as RT118551$

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 20, 2013

From Michael.Jacob3@de.ibm.com

Created by DE113631@BROADBRICK

If the serialized form returned by STORABLE_freeze() is the empty string
STORABLE_thaw()/_attach() will be fed undef instead.

(This may be intended but not documented.)

package xyz;

use Storable qw(freeze thaw);

sub new {
  my $class = shift;
  my $string = shift;
  die 'Bad data' unless defined $string;
  my $self = { string => $string };
  return bless $self, $class;
}

sub STORABLE_freeze {
  my $self = shift;
  my $cloning = shift;
  return if $cloning;
  return ($self->{string});
}

sub STORABLE_attach {
  my $class = shift;
  my $cloning = shift;
  my $string = shift;
  return $class->new($string);
}

print $Storable​::VERSION, "\n"; # 2.39

$a = [ xyz->new('a'), xyz->new('') ];

$b = freeze($a);

thaw($b); # <-- dies here with "Bad data"

Perl Info

Flags:
    category=library
    severity=low
    module=Storable

Site configuration information for perl 5.10.1:

Configured by rurban at Fri Dec 18 14:51:24 GMT 2009.

Summary of my perl5 (revision 5 version 10 subversion 1) configuration:

  Platform:
    osname=cygwin, osvers=1.7.0(0.21853), 
archname=i686-cygwin-thread-multi-64int
    uname='cygwin_nt-5.1 reini 1.7.0(0.21853) 2009-12-04 17:08 i686 cygwin 
'
    config_args='-de -Dlibperl=cygperl5_10.dll -Dmksymlinks -Dusethreads 
-Doptimize=-O3'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=undef, uselongdouble=undef
    usemymalloc=y, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ 
-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include',
    optimize='-O3',
    cppflags='-DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ 
-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.3.4 20090804 (release) 1', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, 
Off_t='off_t', lseeksize=8
"perlbug.rep" 98 lines, 4142 characters
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='g++', ldflags =' -Wl,--enable-auto-import -Wl,--export-all-symbols 
-Wl,--stack,8388608 -Wl,--enable-auto-image-base -fstack-
protector -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib /lib
    libs=-lgdbm -ldb -ldl -lcrypt -lgdbm_compat
    perllibs=-ldl -lcrypt
    libc=/usr/lib/libc.a, so=dll, useshrplib=true, libperl=cygperl5_10.dll
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' --shared  -Wl,--enable-auto-import 
-Wl,--export-all-symbols -Wl,--stack,8388608 -Wl,--enable-auto-im
age-base -L/usr/local/lib -fstack-protector'

Locally applied patches:
    CYG11 no-bs
    CYG12 no archlib in otherlibdirs
    CYG14 Dynaloader
    CYG15 static-Win32CORE
    CYG17 utf8-paths
    CYG21 LibList-Kid.patch
    CYG22 cygwin-1.7 hints
    CYG23 544-stat
    CYG24 build man pages
    CYG26 Cwd for svk
    Bug#55162 File::Spec::case_tolerant performance
    disable ExtUtils::MakeMaker::Coverage in Sys-Syslog


@INC for perl 5.10.1:
    /usr/lib/perl5/5.10/i686-cygwin
    /usr/lib/perl5/5.10
    /usr/lib/perl5/site_perl/5.10/i686-cygwin
    /usr/lib/perl5/site_perl/5.10
    /usr/lib/perl5/vendor_perl/5.10/i686-cygwin
    /usr/lib/perl5/vendor_perl/5.10
    /usr/lib/perl5/vendor_perl/5.10
    /usr/lib/perl5/site_perl/5.8
    /usr/lib/perl5/vendor_perl/5.8
    .


Environment for perl 5.10.1:
    HOME=/home/xxxxxxxx
    LANG=C.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
 
PATH=/usr/local/APACHE~1.2/bin/:/usr/local/bin:/usr/bin:/usr/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Wi
ndows/System32/Wbem:/cygdrive/c/PROGRA~1/IBM/INFOPR~1:/cygdrive/c/Notes:/cygdrive/c/lotus/compnent:/cygdrive/c/UTILIT~1:/cygdrive/c/
PROGRA~1/IBM/PERSON~1/:/cygdrive/c/PROGRA~1/IBM/TRACEF~1/:/cygdrive/c/PROGRA~1/ThinkPad/CONNEC~1:/cygdrive/c/WINDOWS/DOWNLO~1:/cygdr
ive/d/DB2/SQLLIB/BIN:/cygdrive/d/DB2/SQLLIB/FUNCTION:/cygdrive/d/DB2/SQLLIB/SAMPLES/REPL:/cygdrive/c/PROGRA~1/Intel/WiFi/bin/:/usr/b
in:/cygdrive/c/PROGRA~1/OpenVPN/bin:/cygdrive/c/PROGRA~1/IDMCOM~1/ULTRAE~1/:/cygdrive/c/wamp/bin/php/php5.3.0
    PERL_BADLANG (unset)
    SHELL (unset)
~
~
~

/mfg/
Michael Jacob

############################################################
Mobile: +49-172-6350425
############################################################
IBM Deutschland Enterprise Application Solutions GmbH
Geschäftsführung: Dr. Uwe Groß, Michael Mai
Sitz der Gesellschaft: Ehningen
Registergericht: Amtsgericht Stuttgart, HRB 726152
############################################################


@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 20, 2013

From @jkeenan

On Thu Jun 20 09​:31​:42 2013, Michael.Jacob3@​de.ibm.com wrote​:

This is a bug report for perl from DE113631@​BROADBRICK,
generated with the help of perlbug 1.39 running under perl 5.10.1.

-----------------------------------------------------------------
[Please describe your issue here]

If the serialized form returned by STORABLE_freeze() is the empty
string
STORABLE_thaw()/_attach() will be fed undef instead.

(This may be intended but not documented.)

package xyz;

use Storable qw(freeze thaw);

sub new {
my $class = shift;
my $string = shift;
die 'Bad data' unless defined $string;
my $self = { string => $string };
return bless $self, $class;
}

sub STORABLE_freeze {
my $self = shift;
my $cloning = shift;
return if $cloning;
return ($self->{string});
}

sub STORABLE_attach {
my $class = shift;
my $cloning = shift;
my $string = shift;
return $class->new($string);
}

print $Storable​::VERSION, "\n"; # 2.39

$a = [ xyz->new('a'), xyz->new('') ];

$b = freeze($a);

thaw($b); # <-- dies here with "Bad data"

I can confirm that this also occurs with blead and Storable 2.43.

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 20, 2013

The RT System itself - Status changed from 'new' to 'open'

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Dec 6, 2017

From @tonycoz

On Thu, 20 Jun 2013 16​:39​:49 -0700, jkeenan wrote​:

On Thu Jun 20 09​:31​:42 2013, Michael.Jacob3@​de.ibm.com wrote​:

This is a bug report for perl from DE113631@​BROADBRICK,
generated with the help of perlbug 1.39 running under perl 5.10.1.

-----------------------------------------------------------------
[Please describe your issue here]

If the serialized form returned by STORABLE_freeze() is the empty
string
STORABLE_thaw()/_attach() will be fed undef instead.

(This may be intended but not documented.)

package xyz;

use Storable qw(freeze thaw);

sub new {
my $class = shift;
my $string = shift;
die 'Bad data' unless defined $string;
my $self = { string => $string };
return bless $self, $class;
}

sub STORABLE_freeze {
my $self = shift;
my $cloning = shift;
return if $cloning;
return ($self->{string});
}

sub STORABLE_attach {
my $class = shift;
my $cloning = shift;
my $string = shift;
return $class->new($string);
}

print $Storable​::VERSION, "\n"; # 2.39

$a = [ xyz->new('a'), xyz->new('') ];

$b = freeze($a);

thaw($b); # <-- dies here with "Bad data"

I can confirm that this also occurs with blead and Storable 2.43.

Fixed in my working Storable branch tonyc/127743-cperl-storable-fixes

Tony

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Aug 6, 2019

From @tonycoz

On Thu, 20 Jun 2013 09​:31​:42 -0700, Michael.Jacob3@​de.ibm.com wrote​:

If the serialized form returned by STORABLE_freeze() is the empty
string
STORABLE_thaw()/_attach() will be fed undef instead.

(This may be intended but not documented.)

package xyz;

use Storable qw(freeze thaw);

sub new {
my $class = shift;
my $string = shift;
die 'Bad data' unless defined $string;
my $self = { string => $string };
return bless $self, $class;
}

sub STORABLE_freeze {
my $self = shift;
my $cloning = shift;
return if $cloning;
return ($self->{string});
}

sub STORABLE_attach {
my $class = shift;
my $cloning = shift;
my $string = shift;
return $class->new($string);
}

print $Storable​::VERSION, "\n"; # 2.39

$a = [ xyz->new('a'), xyz->new('') ];

$b = freeze($a);

thaw($b); # <-- dies here with "Bad data"

The fix for this was merged into blead as 4896813 and released as part of perl 5.28.0.

Thanks for the report.

Closing.

Tony

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Aug 6, 2019

@tonycoz - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.