develooper Front page | perl.perl5.porters | Postings from November 2016

[perl #130188] crash on return from substitution in subroutine

Thread Previous | Thread Next
Wolf-Dietrich Moeller
November 27, 2016 10:36
[perl #130188] crash on return from substitution in subroutine
Message ID:
# New Ticket Created by  Wolf-Dietrich Moeller 
# Please include the string:  [perl #130188]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This is a bug report for perl from,
generated with the help of perlbug 1.40 running under perl 5.24.0.

[Please describe your issue here]

On execution of a perl script with "perl -w" perl crashes
without any compile or runtime message or warning.
An operating system "perl.exe - Application Error" window appears
in my Win XP SP3 installation. The error window reads:
 'The instruction at "0x...." referenced memory at "0x....".
  The memory could not be "read"'.

The crash happens when returning from a subroutine with "return without
from the replacement part of a substitution s///e.
According to perlfunc return without EXPR should return "()" in list context
and "undef" in scalar context.

The test program below shows in "a..c" the cases where perl
works correctly (non-empty return from substitution or
return with explicit EXPR = "()" or "undef").
In "d" on return in list context still everything is fine
(an empty list is returned, see "d" in test case).
But on return in scalar context the crash happens.

#### begin test code

sub tst ($) {
 shift =~ s/(.)/return $1 if $1 eq 'a'; return () if $1 eq 'b'; return undef
if $1 eq 'c'; return if $1 eq 'd'; 'F'/er
my ($y,$z,$i);
for (qw'a b c d') {
 print STDERR "\$_='$_'\n";
 $i = ($y) = tst($_);
 print STDERR "list context: y='",$y//'undef',"', length return-list=$i";
 $z = tst($_);
 print STDERR ", scalar context: z='",$z//'undef',"'\n\n";

#### end test code

The console output of "perl -w" is:

#### begin output
list context: y='a', length return-list=1, scalar context: z='a'

list context: y='undef', length return-list=0, scalar context: z='undef'

list context: y='undef', length return-list=1, scalar context: z='undef'

list context: y='undef', length return-list=0
#### end output

Here the crash happens before the print for $z (scalar context) is executed.

[Please do not change anything below this line]
Site configuration information for perl 5.24.0:

Configured by strawberry-perl at Tue May 10 17:12:25 2016.

Summary of my perl5 (revision 5 version 24 subversion 0) configuration:
    osname=MSWin32, osvers=6.3, archname=MSWin32-x86-multi-thread-64int
    uname='Win32 strawberry-perl #1 Tue May 10 17:10:11 2016 i386'
    hint=recommended, useposix=true, d_sigaction=undef
    useithreads=define, usemultiplicity=define
    use64bitint=define, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
    cc='gcc', ccflags =' -s -O2 -DWIN32  -DPERL_TEXTMODE_SCRIPTS
-DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fwrapv -fno-strict-aliasing
    optimize='-s -O2',
    ccversion='', gccversion='4.9.2', 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='long
long', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='g++', ldflags ='-s -L"C:\Perl\perl\lib\CORE" -L"C:\Perl\c\lib"'
    libpth=C:\Perl\c\lib C:\Perl\c\i686-w64-mingw32\lib
    libs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32
-ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr
-lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    perllibs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32
-ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr
-lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    libc=, so=dll, useshrplib=true, libperl=libperl524.a
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=xs.dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-mdll -s -L"C:\Perl\perl\lib\CORE"

@INC for perl 5.24.0:

Environment for perl 5.24.0:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=C:\Documents and Settings\All Users\Application
Data\Oracle\Java\javapath;C:\Program Files\Perl\site\bin;C:\Program
ogram Files\Windows
    PERL_BADLANG (unset)
    SHELL (unset)

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About