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

eval STRING compilation failure breaks overloading #10733

Closed
p5pRT opened this issue Oct 15, 2010 · 7 comments
Closed

eval STRING compilation failure breaks overloading #10733

p5pRT opened this issue Oct 15, 2010 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Oct 15, 2010

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

Searchable as RT78398$

@p5pRT
Copy link
Author

p5pRT commented Oct 15, 2010

From hdp@glaive.weftsoar.net

Created by hdp@glaive.weftsoar.net

Using eval STRING inside an overload method causes stack corruption when STRING
has compile-time errors.

Commenting out the eval makes it work; or changing it to just eval "require Foo​::Bar"
putting it inside { local $@​; eval ... } makes it abort​:
perl​: pp_ctl.c​:2073​: Perl_pp_leaveloop​: Assertion `(((cx)->cx_u.cx_subst.sbu_type & 0xC) == 0x4)' fail.
perl 5.10.1 and 5.8.9 segfault here instead of aborting.
Any compile-time error works, like "BEGIN { !@​#!@​# }" or "use Foo​::Bar"

use overload (q{""} => 'str');
sub new { bless {} }
sub str {
  eval "BEGIN { require Foo​::Bar }";
  return 1;
}

main->new() . "";

Perl Info

Flags:
    category=core
    severity=high

Site configuration information for perl 5.10.1:

Configured by hdp at Sun Apr 11 07:47:29 EDT 2010.

Summary of my perl5 (revision 5 version 10 subversion 1) configuration:
   
  Platform:
    osname=linux, osvers=2.6.31.5-linode21, archname=i686-linux
    uname='linux glaive 2.6.31.5-linode21 #1 smp mon oct 26 18:17:01 utc 2009 i686 gnulinux '
    config_args='-de -Dprefix=/home/hdp/perl5/perlbrew/perls/perl-5.10.1'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.3.3', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /usr/lib64
    libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.9.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.9'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector'

Locally applied patches:
    


@INC for perl 5.10.1:
    /home/hdp/perl5/perlbrew/perls/perl-5.10.1/lib/5.10.1/i686-linux
    /home/hdp/perl5/perlbrew/perls/perl-5.10.1/lib/5.10.1
    /home/hdp/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/i686-linux
    /home/hdp/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1
    .


Environment for perl 5.10.1:
    HOME=/home/hdp
    LANG=en_US.UTF8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/hdp/perl5/perlbrew/bin:/home/hdp/perl5/perlbrew/perls/current/bin:/home/hdp/bin:/home/hdp/local/bin:/home/hdp/local/sbin:/var/lib/gems/1.8/bin:/home/hdp/.inker/perl/bin:/home/hdp/bin:/home/hdp/local/bin:/home/hdp/local/sbin:/var/lib/gems/1.8/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
    PERL_BADLANG (unset)
    PERL_CPANM_OPT=--prompt --skip-installed --mirror http://cpan.cpantesters.org
    SHELL=/usr/bin/zsh

@p5pRT
Copy link
Author

p5pRT commented Oct 15, 2010

From hdp@pobox.com

I tested this with all of 5.12.2, 5.10.1, and 5.8.9, and it breaks in
the same way under all of them.

@p5pRT
Copy link
Author

p5pRT commented Oct 16, 2010

From @rafl

For me, it fails slightly differently.

"Can't return outside a subroutine at" from the return in the overloaded
method.

This is probably the same problem you're seeing, but with a different
effect. It might indicate that the exception is unwinding a little too far?

Also, I can't produce this on blead. I can't see any recent changes to
amagic_call and friends that would fix anything like that. Is it
possible that the general exception sanity fixes took care of this as well?

A bisect run, anyone?

@p5pRT
Copy link
Author

p5pRT commented Oct 16, 2010

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

@p5pRT
Copy link
Author

p5pRT commented Oct 16, 2010

From hdp@pobox.com

On Sat Oct 16 02​:08​:25 2010, rafl wrote​:

"Can't return outside a subroutine at" from the return in the overloaded
method.

Sorry, I forgot to say what the actual error is. :)

That's what I get too. The segfault/abort is only if I try to localize
$@​ around the eval.

@p5pRT
Copy link
Author

p5pRT commented Oct 16, 2010

From @rafl

Apparently this is already fixed in 5.13.0. Here's the bisect result.

git bisect start
# bad​: [a4ef294] Add 5.13.0 to perlhist
git bisect bad a4ef294
# good​: [6d52c88] Removing the RC
marker from patchlevel.h
git bisect good 6d52c88
# bad​: [d1515be] mark two magic.t tests
as TODO
git bisect bad d1515be
# bad​: [1bb125e] Note how to deal with
broken dbm.h on OpenSUSE
git bisect bad 1bb125e
# bad​: [11035fc] remove 'enable taint
if modify gid/uid' feature
git bisect bad 11035fc
# good​: [099be4f] PL_defoutgv isn't
always a GV.
git bisect good 099be4f
# bad​: [27e9045] fix RT 23810​: eval and
tied methods
git bisect bad 27e9045
# good​: [91e35ba] more mods to -Dl
debugging output
git bisect good 91e35ba

27e9045 is the first bad commit
commit 27e9045
Author​: David Mitchell <davem@​iabyn.com>
Date​: Thu Apr 8 13​:16​:56 2010 +0100

  fix RT 23810​: eval and tied methods

  Something like the following ended up corrupted​:
  sub FETCH { eval 'BEGIN{syntax err}' }
  The croak on error popped back the context stack etc to the EVAL
pushed by
  entereval, but the corresponding JUMPENV_PUSH(3) unwound all the way
to the
  outer perl_run, losing all the mg_get() related parts of the C stack.

  It turns out that the run-time parts of pp_entereval were protected with
  a new JUMPENV level, but the compile-time parts weren't. Add this.

:100644 100644 80c7b221d7e967a6f3380d70917bd73700b16852
bbb2d1587cb197977c996ecfe8abddf4f9aa3631 M pp_ctl.c
:040000 040000 7fa8480b6084b533c3eaddbbbd6834e2551f8a4e
f2ec8022695df42cff76ab78c117bd44d1fb626c M t

So I'm closing this. Tests for this particular issue in combination with
overload might be a good thing.

@p5pRT
Copy link
Author

p5pRT commented Oct 16, 2010

@rafl - 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
Development

No branches or pull requests

1 participant