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

5.10.0 crash on serialised v-strings #9404

Closed
p5pRT opened this issue Jul 4, 2008 · 7 comments
Closed

5.10.0 crash on serialised v-strings #9404

p5pRT opened this issue Jul 4, 2008 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Jul 4, 2008

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

Searchable as RT56606$

@p5pRT
Copy link
Author

p5pRT commented Jul 4, 2008

From abuse@cabal.org.uk

This is a bug report for perl from abuse@​cabal.org.uk,
generated with the help of perlbug 1.36 running under perl 5.10.0.


Attempts to stringify version objects that do not have an 'original' field
cause Perl 5.10.0 (in at least the Debian incarnation) to segfault. Such
objects can be created either by hand, as I have done in these examples, or
by deserialising a serialised version object created by an earlier version
of Perl.

Here is a correctly-formed version object​:

$ perl -MData​::Dumper -Mversion -e 'print Dumper qv(1.2.3)'
$VAR1 = bless( {
  'original' => 'v1.2.3',
  'qv' => 1,
  'version' => [
  1,
  2,
  3
  ]
  }, 'version' );

And here's how to trigger the segfault​:

$ perl -e 'print bless { version => [1,2,3] }, "version"'
Segmentation fault
$

And it working with the 'original' field​:

$ perl -e 'print bless { original => 'v1.2.3', version => [1,2,3]}, "version"'
v1.2.3

(Perl 5.8.8 outputs something like "version=HASH(0x1800634)" in both cases.)

I'm somewhat aware that it's a case of "don't do that", but such serialised
version objects already exist in the wild in the form of CPAN META.yml files
and Perl ought to be able to do something sensible when confronted with
them. Here's one, for example​:

http​://www.cpan.org/pub/CPAN/authors/id/K/KR/KRUSCOE/Tie-DxHash-v1.0.0.meta



Flags​:
  category=core
  severity=low


Site configuration information for perl 5.10.0​:

Configured by Debian Project at Sat Jun 21 19​:18​:10 UTC 2008.

Summary of my perl5 (revision 5 version 10 subversion 0) configuration​:
  Platform​:
  osname=linux, osvers=2.6.18-6-xen-amd64, archname=x86_64-linux-gnu-thread-multi
  uname='linux sid 2.6.18-6-xen-amd64 #1 smp fri jun 6 06​:38​:05 utc 2008 x86_64 gnulinux '
  config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=x86_64-linux-gnu -Dprefix=/usr -Dprivlib=/usr/share/perl/5.10 -Darchlib=/usr/lib/perl/5.10 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.10.0 -Dsitearch=/usr/local/lib/perl/5.10.0 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Ud_ualarm -Uusesfio -Uusenm -DDEBUGGING=-g -Doptimize=-O2 -Duseshrplib -Dlibperl=libperl.so.5.10.0 -Dd_dosuid -des'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=define, usemultiplicity=define
  useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
  use64bitint=define, use64bitall=define, uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
  optimize='-O2 -g',
  cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -I/usr/local/include'
  ccversion='', gccversion='4.3.1', gccosandvers=''
  intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='cc', ldflags =' -L/usr/local/lib'
  libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64
  libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt
  perllibs=-ldl -lm -lpthread -lc -lcrypt
  libc=/lib/libc-2.7.so, so=so, useshrplib=true, libperl=libperl.so.5.10.0
  gnulibc_version='2.7'
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
  cccdlflags='-fPIC', lddlflags='-shared -O2 -g -L/usr/local/lib'

Locally applied patches​:
 


@​INC for perl 5.10.0​:
  /etc/perl
  /usr/local/lib/perl/5.10.0
  /usr/local/share/perl/5.10.0
  /usr/lib/perl5
  /usr/share/perl5
  /usr/lib/perl/5.10
  /usr/share/perl/5.10
  /usr/local/lib/site_perl
  .


Environment for perl 5.10.0​:
  HOME=/home/abuse
  LANG=en_GB.UTF-8
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/home/abuse/bin​:/usr/local/bin​:/usr/bin​:/bin​:/usr/games
  PERL_BADLANG (unset)
  SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jul 8, 2008

From @JohnPeacock

abuse@​cabal.org.uk (via RT) wrote​:

Attempts to stringify version objects that do not have an 'original' field
cause Perl 5.10.0 (in at least the Debian incarnation) to segfault. Such
objects can be created either by hand, as I have done in these examples, or
by deserialising a serialised version object created by an earlier version
of Perl.

I hate Data​::Dumper (this is the second time I've had to work around its
profound limitations wrt objects). :(

I've added a test and have a fix for the CPAN compatibility release. I'm just
working out which [profoundly evil] namespace hackery I have to do in order to
get this to work with Perl 5.10.0 until 5.10.1 comes out...

John

@p5pRT
Copy link
Author

p5pRT commented Jul 8, 2008

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

@p5pRT
Copy link
Author

p5pRT commented Jul 9, 2008

From @JohnPeacock

John Peacock wrote​:

I'm just working out which [profoundly evil] namespace hackery I have to
do in order to get this to work with Perl 5.10.0 until 5.10.1 comes out...

I've got a fix for the segfault, but in order for it to take effect, you have to
install the CPAN version.pm release in 5.10.0 *AND* call 'use version;'
someplace in your code. I can't patch the Perl binary/library (obviously), so
the only way the updated code can take effect is through loading the new files.
  It's too bad that no one builds Perl to support the sitecustomize.pl file...

The big problem with this limitation is that the major recipients of coredumps
are going to be people using CPAN to install modules that have badly serialized
META.yml files. So what do I do? Do I patch CPAN.pm to 'use version;' as part
of installing version.pm, just to force the correct code path to be followed?
Anyone have any better ideas? Can we release v5.10.1 in time for OSCON???

And before anyone says "Why didn't you keep version.pm separate from the core so
you could easily update it?" - because Perl is using the version-object code
itself as part of module loading, so it has to be there already before you can
'use' it...

John

@p5pRT
Copy link
Author

p5pRT commented Jul 15, 2008

From @rgs

2008/7/12 John Peacock <john.peacock@​havurah-software.org>​:

Attached, please find a patch to bleadperl that fixes the referenced
segfault on improperly serialized version objects. This can be merged to
maint-5.10 so that v5.10.1 won't segfault any longer.

Thanks, applied as #34142 (although apparently your patch was against 5.10.x)

I'm still not sure what to do about the CPAN release to deal with existing
v5.10.0 installations. I have a way of installing version.pm that works
with Perl v5.10.0, but it requires 'use version' to be called firt. There
is no way for me to force that call to happen automagically, short of
patching some other core module that [virtually] everyone calls already
(like Exporter?).

Does anyone have any better idea?

Not really, sorry.

@p5pRT
Copy link
Author

p5pRT commented Aug 2, 2008

From p5p@spam.wizbit.be

Binary search​:

./perl-p-5.8.0\@​17818/miniperl -l test.pl
version=HASH(0x8123904)

./perl-p-5.8.0\@​17821/miniperl -l test.pl
0

(Had some problems compiling 17819/17820)

http​://public.activestate.com/cgi-bin/perlbrowse/p/17819
Change 17819 by hv@​hv-crypt.org on 2002/08/30 13​:42​:02

  Subject​: [PATCH] Tweaks to Bleadperl Version Object Support
  From​: John Peacock <jpeacock@​rowman.com>
  Date​: Wed, 28 Aug 2002 22​:13​:48 -0400
  Message-ID​: <3D6D835C.50809@​rowman.com>

./perl-p-5.8.0\@​17989/miniperl -l test.pl
0

./perl-p-5.8.0\@​17991/miniperl -l test.pl
Segmentation fault

(Had problems compiling 17990)

Change 17990 by hv@​hv-crypt.org on 2002/10/10 11​:19​:57

  Subject​: [PATCH] Version object combined patch
  From​: John Peacock <jpeacock@​rowman.com>
  Date​: Fri, 04 Oct 2002 23​:15​:10 -0400
  Message-ID​: <3D9E593E.1060605@​rowman.com>

Change 17991 by hv@​hv-crypt.org on 2002/10/10 11​:20​:41

  new files lib/version.pm and lib/version.t for change #17990.

@p5pRT
Copy link
Author

p5pRT commented Jan 7, 2012

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant