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

return out of first {body} #7225

Closed
p5pRT opened this issue Apr 10, 2004 · 8 comments
Closed

return out of first {body} #7225

p5pRT opened this issue Apr 10, 2004 · 8 comments

Comments

@p5pRT
Copy link

p5pRT commented Apr 10, 2004

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

Searchable as RT28438$

@p5pRT
Copy link
Author

p5pRT commented Apr 10, 2004

From @lizmat

Created by @lizmat

in 5.8.0, the following neatly returns an error message.

-bash-2.05b$ perl5.8.0 -MList​::Util=first -e 'first {return 1} (1)'
Can't return outside a subroutine at -e line 1.

in 5.8.1 and higher (including 5.8.4-RC1 and 5.9.0) gives a segfault​:

$ valgrind perl5.8.3 -MList​::Util=first -e 'first {return 1} (1)'
==18250== Invalid read of size 4
==18250== at 0x80CC91E​: Perl_pp_entersub (pp_hot.c​:2852)
==18250== by 0x80AF46A​: Perl_runops_debug (dump.c​:1438)
==18250== by 0x80624D7​: S_run_body (perl.c​:1857)
==18250== by 0x8062066​: perl_run (perl.c​:1776)
==18250== Address 0x0 is not stack'd, malloc'd or free'd
Segmentation fault

Perl Info

Flags:
     category=core
     severity=medium

This perlbug was built using Perl v5.8.3 - Wed Jan 14 23:55:23 CET 2004
It is being executed now by  Perl v5.8.2 - Fri Nov  7 13:22:20 CET 2003.

Site configuration information for perl v5.8.2:

Configured by liz at Fri Nov  7 13:22:20 CET 2003.

Summary of my perl5 (revision 5.0 version 8 subversion 2) configuration:
   Platform:
     osname=linux, osvers=2.4.20-8, archname=i686-linux
     uname='linux cadier.hsyndicate.com 2.4.20-8 #1 thu mar 13 
17:54:28 est 2003 i686 i686 i386 gnulinux '
     config_args='-de'
     hint=recommended, useposix=true, d_sigaction=define
     usethreads=undef use5005threads=undef 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 -I/usr/local/include 
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
     optimize='-O3',
     cppflags='-fno-strict-aliasing -I/usr/local/include -I/usr/include/gdbm'
     ccversion='', gccversion='3.2.2 20030222 (Red Hat Linux 
3.2.2-5)', 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 =' -L/usr/local/lib'
     libpth=/usr/local/lib /lib /usr/lib
     libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
     perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
     libc=/lib/libc-2.3.2.so, so=so, useshrplib=false, libperl=libperl.a
     gnulibc_version='2.3.2'
   Dynamic Linking:
     dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
     cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:



@INC for perl v5.8.2:
     /usr/local/lib/perl5/5.8.2/i686-linux
     /usr/local/lib/perl5/5.8.2
     /usr/local/lib/perl5/site_perl/5.8.2/i686-linux
     /usr/local/lib/perl5/site_perl/5.8.2
     /usr/local/lib/perl5/site_perl/5.8.1/i686-linux
     /usr/local/lib/perl5/site_perl/5.8.1
     /usr/local/lib/perl5/site_perl
     .


Environment for perl v5.8.2:
     HOME=/home/liz
     LANG=en_US.UTF-8
     LANGUAGE (unset)
     LD_LIBRARY_PATH (unset)
     LOGDIR (unset)
 
PATH=/usr/local/mysql/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/liz/bin
     PERL_BADLANG (unset)
     SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Apr 11, 2004

From @andk

On 10 Apr 2004 19​:46​:42 -0000, Elizabeth Mattijsen (via RT) <perlbug-followup@​perl.org> said​:

Blame analysis​:

----Program----
use List​::Util qw=first=;
first {return 1} (1)

----Output of .../pDGfVX1/perl-5.8.0@​18075/bin/perl----
Can't return outside a subroutine at tests/liz_first.pl line 2.

----EOF ($?='65280')----
----Output of .../ptxQFdw/perl-5.8.0@​18076/bin/perl----

----EOF ($?='11')----

Change 18076 by gbarr@​monty on 2002/11/03 10​:11​:18

  Update to Scalar-List-Utils 1.08

--
andreas

@p5pRT
Copy link
Author

p5pRT commented Apr 11, 2004

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

@p5pRT
Copy link
Author

p5pRT commented Apr 11, 2004

From @iabyn

On Sun, Apr 11, 2004 at 09​:44​:20AM +0200, Andreas J Koenig wrote​:

On 10 Apr 2004 19​:46​:42 -0000, Elizabeth Mattijsen (via RT) <perlbug-followup@​perl.org> said​:

Blame analysis​:

Change 18076 by gbarr@​monty on 2002/11/03 10​:11​:18

    Update to Scalar\-List\-Utils 1\.08

Well, the direct segfault happens because the return pops a SUB context
off the stack, then the loop in first() also tries to pop it off.

Not sure of the best way of fixing this.

--
"There's something wrong with our bloody ships today, Chatfield."
Admiral Beatty at the Battle of Jutland, 31st May 1916.

@p5pRT
Copy link
Author

p5pRT commented Jul 6, 2016

From @dcollinsn

This /appears/ to be fixed. Taking with the intent to bisect this afternoon.

@p5pRT
Copy link
Author

p5pRT commented Jul 6, 2016

From @dcollinsn

I can't reproduce this going back to 5.10.0, which is the earliest perl I'm able to build.

@p5pRT
Copy link
Author

p5pRT commented Jul 6, 2016

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

@p5pRT p5pRT closed this as completed Jul 6, 2016
@p5pRT
Copy link
Author

p5pRT commented Jul 7, 2016

From @iabyn

On Wed, Jul 06, 2016 at 01​:13​:39PM -0700, Dan Collins via RT wrote​:

I can't reproduce this going back to 5.10.0, which is the earliest perl
I'm able to build.

The fix bisects to 3 commits, one of which is

  commit 9850bf2
  Author​: Robin Houston <robin@​cpan.org>
  AuthorDate​: Sat Oct 29 22​:33​:07 2005 +0100
  Commit​: H.Merijn Brand <h.m.brand@​xs4all.nl>
  CommitDate​: Wed Nov 2 12​:49​:54 2005 +0000

  sort/multicall patch
  Message-ID​: <20051029203307.GA8869@​rpc142.cs.man.ac.uk>
 
  p4raw-id​: //depot/perl@​25953

which sounds plausible that it fixed it.

--
A power surge on the Bridge is rapidly and correctly diagnosed as a faulty
capacitor by the highly-trained and competent engineering staff.
  -- Things That Never Happen in "Star Trek" #9

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