On 29 May 2010 20:19, Ævar Arnfjörð Bjarmason <perlbug-followup@perl.org> wrote: > This segfaults in everything from 5.10 to blead: > > perl -e 'sub eek { my $_ = $_[0]; reverse } eek(1)' Thanks for tracing this down. Some background : reverse() without arguments is special, because it defaults to $_ only when called in scalar context. That means that, unlike all other builtins that default to $_, you can't know at compile time whether it will read $_ or not, and you can't put this info in the optree. So you have to figure it out later, at runtime. find_rundefsvoffset() locates a lexical $_ in the pad at runtime; however we don't know if it's a "my" or an "our", and in this case the segfault is produced in the part of the statement: PAD_COMPNAME_FLAGS_isOUR(padoff_du), which doesn't work, because apparently it's intended for compile-time, not run-time. The path below fixes the segfault, but with it the behaviour of the following one-liner is incorrect: $ bleadperl -le 'sub eek { our $_ = $_[0]; reverse } print 1+ eek(12);print' 1 12 (the first value should be 22 = 1 + 21 = 1 + reverse(12)) (This is incorrect but still better than a segfault as in blead currently...) I'd appreciate a hint -- how can I test at run-time the SVpad_* flags of a variable in the pad ? --- a/pp.c +++ b/pp.c @@ -5498,8 +5498,7 @@ PP(pp_reverse) sv_setsv(TARG, (SP > MARK) ? *SP : (padoff_du = find_rundefsvoffset(), - (padoff_du == NOT_IN_PAD - || PAD_COMPNAME_FLAGS_isOUR(padoff_du)) + padoff_du == NOT_IN_PAD ? DEFSV : PAD_SVl(padoff_du))); if (! SvOK(TARG) && ckWARN(WARN_UNINITIALIZED))Thread Previous | Thread Next