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

$_ incorrect within for loop inside map #14269

Closed
p5pRT opened this issue Nov 23, 2014 · 18 comments

Comments

@p5pRT
Copy link
Collaborator

@p5pRT p5pRT commented Nov 23, 2014

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

Searchable as RT123286$

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Nov 23, 2014

From @stas53

Cc​: s.romanski@​datos.pl
Subject​: Strange $_ inside 'for' nested in 'map' - bug or feature ?
Message-Id​: <5.16.3_5548_1416780247@​DATOS-57604FE5B>
Reply-To​: s.romanski@​datos.pl
To​: perlbug@​perl.org
From​: s.romanski@​datos.pl

This is a bug report for perl from s.romanski@​datos.pl,
generated with the help of perlbug 1.39 running under perl 5.16.3.

#!perl -w
# test447.pl
# With the commented-out instruction in the line 11
# - this code prints strange values for the table elements of indices 1 and 2. Why ?
# Un-commenting the line 11 - or inserting any other instruction inside 'map' or 'for'
# - makes the code to run properly. Bug or feature ?

use strict;
use warnings;
map {
# my $this_instruction_seems_to_be_completely_irrelevant = 111;
  for (my $i = 0; $i <= 0; $i++ ) {
  print "$_\n";
  }
  } ('abc', 'def', 'ghi', 'jkl', 'mno');


Flags​:
  category=core
  severity=high


Site configuration information for perl 5.16.3​:

Configured by gecko at Wed Mar 13 11​:25​:21 2013.

Summary of my perl5 (revision 5 version 16 subversion 3) configuration​:
 
  Platform​:
  osname=MSWin32, osvers=5.2, archname=MSWin32-x86-multi-thread
  uname=''
  config_args='undef'
  hint=recommended, useposix=true, d_sigaction=undef
  useithreads=define, usemultiplicity=define
  useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
  use64bitint=undef, use64bitall=undef, uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cl', ccflags ='-nologo -GF -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DPERL_TEXTMODE_SCRIPTS -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T',
  optimize='-MD -Zi -DNDEBUG -O1',
  cppflags='-DWIN32'
  ccversion='12.0.8168', gccversion='', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
  d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=8
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='link', ldflags ='-nologo -nodefaultlib -debug -opt​:ref,icf -libpath​:"D​:\Perl\lib\CORE" -machine​:x86'
  libpth=\lib
  libs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
  perllibs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
  libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl516.lib
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
  cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -opt​:ref,icf -libpath​:"D​:\Perl\lib\CORE" -machine​:x86'

Locally applied patches​:
  ACTIVEPERL_LOCAL_PATCHES_ENTRY


@​INC for perl 5.16.3​:
  .
  D​:\Perl\lib
  D​:\Perl\site\lib
  D​:/Perl/site/lib
  D​:/Perl/lib
  .


Environment for perl 5.16.3​:
  HOME (unset)
  LANG (unset)
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=D​:\Perl\site\bin;D​:\Perl\bin;C​:\Program Files\PC Connectivity Solution\;C​:\Python27\;C​:\Python27\Scripts;C​:\Oracle\product\10.1.0\Client_1\bin;C​:\Oracle\product\10.1.0\Client_1\jre\1.4.2\bin\client;C​:\Oracle\product\10.1.0\Client_1\jre\1.4.2\bin;C​:\product\11.1.0\client_1;C​:\WINDOWS\system32;C​:\WINDOWS;C​:\WINDOWS\system32\WBEM;c​:\Program Files\ActiveState Perl Dev Kit 6.0\bin\;c​:\Program Files\ActiveState Komodo 3.5\;c​:\tools;c​:\Tools\pl;C​:\Program Files\Microsoft SQL Server\90\Tools\binn\;C​:\Program Files\MySQL\MySQL Server 5.1\bin;C​:\Program Files\RSA Security\RSA SecurID Software Token\;D​:\Program Files\Oracle\Berkeley DB 11gR2 5.1.25\bin;D​:\Program Files\PostgreSQL\8.4\bin;D​:\Program Files\QuickTime\QTSystem\;%APPDATA%\Python\Scripts;C​:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;C​:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C​:\Program Files\Microsoft Visual Studio\Common\Tools;C​:\Program Files\Microsoft Visual Studio\VC98\bin;d​:\Program Files\gs\gs9.07;C​:\TeXLive2005\bin\win32;c​:\php;c​:\Isis30\sys;C​:\PROGRA1\COMMON1\MUVEET1\030625;;C​:\PROGRA1\COMMON1\MUVEET1\030625
  PERL5LIB=.;D​:\Perl\lib;D​:\Perl\site\lib
  PERLDB_OPTS=RemotePort=127.0.0.1​:2000
  PERL_BADLANG (unset)
  SHELL (unset)

Complete configuration data for perl 5.16.3​:

Author=''
CONFIG='true'
Date='$Date'
Header=''
Id='$Id'
Locker=''
Log='$Log'
PATCHLEVEL='16'
PERL_API_REVISION='5'
PERL_API_SUBVERSION='0'
PERL_API_VERSION='16'
PERL_CONFIG_SH='true'
PERL_PATCHLEVEL=''
PERL_REVISION='5'
PERL_SUBVERSION='3'
PERL_VERSION='16'
RCSfile='$RCSfile'
Revision='$Revision'
SUBVERSION='3'
Source=''
State=''
_a='.lib'
_exe='.exe'
_o='.obj'
afs='false'
afsroot='/afs'
alignbytes='8'
ansi2knr=''
aphostname=''
api_revision='5'
api_subversion='0'
api_version='16'
api_versionstring='5.16.0'
ar='lib'
archlib='D​:\Perl\lib'
archlibexp='D​:\Perl\lib'
archname='MSWin32-x86-multi-thread'
archname64=''
archobjs=''
asctime_r_proto='0'
awk='awk'
baserev='5'
bash=''
bin='D​:\Perl\bin'
binexp='D​:\Perl\bin'
bison=''
byacc='byacc'
byteorder='1234'
c=''
castflags='0'
cat='type'
cc='cl'
cccdlflags=' '
ccdlflags=' '
ccflags='-nologo -GF -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DPERL_TEXTMODE_SCRIPTS -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T'
ccflags_nolargefiles='-nologo -GF -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DPERL_TEXTMODE_SCRIPTS -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T'
ccflags_uselargefiles=''
ccname='cl'
ccsymbols=''
ccversion='12.0.8168'
cf_by='gecko'
cf_email='support@​ActiveState.com'
cf_time='Wed Mar 13 11​:25​:21 2013'
charbits='8'
chgrp=''
chmod=''
chown=''
clocktype='clock_t'
comm=''
compress=''
config_heavy='Config_heavy.pl'
contains='grep'
cp='copy'
cpio=''
cpp='cl -nologo -E'
cpp_stuff='42'
cppccsymbols=''
cppflags='-DWIN32'
cpplast=''
cppminus=''
cpprun='cl -nologo -E'
cppstdin='cppstdin'
cppsymbols=''
crypt_r_proto='0'
cryptlib=''
csh=''
ctermid_r_proto='0'
ctime_r_proto='0'
d_Gconvert='sprintf((b),"%.*g",(n),(x))'
d_PRIEUldbl=''
d_PRIFUldbl=''
d_PRIGUldbl=''
d_PRIXU64=''
d_PRId64=''
d_PRIeldbl=''
d_PRIfldbl=''
d_PRIgldbl=''
d_PRIi64=''
d_PRIo64=''
d_PRIu64=''
d_PRIx64=''
d_SCNfldbl=''
d__fwalk=''
d_access='define'
d_accessx=''
d_aintl=''
d_alarm='define'
d_archlib='define'
d_asctime64=''
d_asctime_r=''
d_atolf=''
d_atoll=''
d_attribute_deprecated=''
d_attribute_format=''
d_attribute_malloc=''
d_attribute_nonnull=''
d_attribute_noreturn=''
d_attribute_pure=''
d_attribute_unused=''
d_attribute_warn_unused_result=''
d_bcmp=''
d_bcopy=''
d_bsd='define'
d_bsdgetpgrp=''
d_bsdsetpgrp=''
d_builtin_choose_expr=''
d_builtin_expect=''
d_bzero=''
d_c99_variadic_macros=''
d_casti32=''
d_castneg='define'
d_charvspr=''
d_chown=''
d_chroot=''
d_chsize='define'
d_class=''
d_clearenv=''
d_closedir='define'
d_cmsghdr_s=''
d_const='define'
d_copysignl=''
d_cplusplus=''
d_crypt='define'
d_crypt_r=''
d_csh=''
d_ctermid=''
d_ctermid_r=''
d_ctime64=''
d_ctime_r=''
d_cuserid=''
d_dbl_dig='define'
d_dbminitproto=''
d_difftime='define'
d_difftime64=''
d_dir_dd_fd=''
d_dirfd=''
d_dirnamlen='define'
d_dlerror='define'
d_dlopen='define'
d_dlsymun=''
d_dosuid=''
d_drand48_r=''
d_drand48proto=''
d_dup2='define'
d_eaccess=''
d_endgrent=''
d_endgrent_r=''
d_endhent=''
d_endhostent_r=''
d_endnent=''
d_endnetent_r=''
d_endpent=''
d_endprotoent_r=''
d_endpwent=''
d_endpwent_r=''
d_endsent=''
d_endservent_r=''
d_eofnblk='define'
d_eunice=''
d_faststdio='define'
d_fchdir=''
d_fchmod=''
d_fchown=''
d_fcntl=''
d_fcntl_can_lock=''
d_fd_macros='define'
d_fd_set='define'
d_fds_bits='define'
d_fgetpos='define'
d_finite=''
d_finitel=''
d_flexfnam='define'
d_flock='define'
d_flockproto='define'
d_fork=''
d_fp_class=''
d_fpathconf=''
d_fpclass=''
d_fpclassify=''
d_fpclassl=''
d_fpos64_t=''
d_frexpl=''
d_fs_data_s=''
d_fseeko=''
d_fsetpos='define'
d_fstatfs=''
d_fstatvfs=''
d_fsync=''
d_ftello=''
d_ftime='define'
d_futimes=''
d_gdbm_ndbm_h_uses_prototypes=''
d_gdbmndbm_h_uses_prototypes=''
d_getaddrinfo=''
d_getcwd='define'
d_getespwnam=''
d_getfsstat=''
d_getgrent=''
d_getgrent_r=''
d_getgrgid_r=''
d_getgrnam_r=''
d_getgrps=''
d_gethbyaddr='define'
d_gethbyname='define'
d_gethent=''
d_gethname='define'
d_gethostbyaddr_r=''
d_gethostbyname_r=''
d_gethostent_r=''
d_gethostprotos='define'
d_getitimer=''
d_getlogin='define'
d_getlogin_r=''
d_getmnt=''
d_getmntent=''
d_getnameinfo=''
d_getnbyaddr=''
d_getnbyname=''
d_getnent=''
d_getnetbyaddr_r=''
d_getnetbyname_r=''
d_getnetent_r=''
d_getnetprotos=''
d_getpagsz=''
d_getpbyname='define'
d_getpbynumber='define'
d_getpent=''
d_getpgid=''
d_getpgrp=''
d_getpgrp2=''
d_getppid=''
d_getprior=''
d_getprotobyname_r=''
d_getprotobynumber_r=''
d_getprotoent_r=''
d_getprotoprotos='define'
d_getprpwnam=''
d_getpwent=''
d_getpwent_r=''
d_getpwnam_r=''
d_getpwuid_r=''
d_getsbyname='define'
d_getsbyport='define'
d_getsent=''
d_getservbyname_r=''
d_getservbyport_r=''
d_getservent_r=''
d_getservprotos='define'
d_getspnam=''
d_getspnam_r=''
d_gettimeod='define'
d_gmtime64=''
d_gmtime_r=''
d_gnulibc=''
d_grpasswd=''
d_hasmntopt=''
d_htonl='define'
d_ilogbl=''
d_inc_version_list=''
d_index=''
d_inetaton=''
d_inetntop=''
d_inetpton=''
d_int64_t=''
d_ipv6_mreq=''
d_isascii='define'
d_isblank=''
d_isfinite=''
d_isinf=''
d_isnan='define'
d_isnanl=''
d_killpg='define'
d_lchown=''
d_ldbl_dig='define'
d_libm_lib_version=''
d_link='define'
d_localtime64=''
d_localtime_r=''
d_localtime_r_needs_tzset=''
d_locconv='define'
d_lockf=''
d_longdbl='define'
d_longlong=''
d_lseekproto='define'
d_lstat=''
d_madvise=''
d_malloc_good_size=''
d_malloc_size=''
d_mblen='define'
d_mbstowcs='define'
d_mbtowc='define'
d_memchr='define'
d_memcmp='define'
d_memcpy='define'
d_memmove='define'
d_memset='define'
d_mkdir='define'
d_mkdtemp=''
d_mkfifo=''
d_mkstemp=''
d_mkstemps=''
d_mktime='define'
d_mktime64=''
d_mmap=''
d_modfl=''
d_modfl_pow32_bug=''
d_modflproto=''
d_mprotect=''
d_msg=''
d_msg_ctrunc=''
d_msg_dontroute=''
d_msg_oob=''
d_msg_peek=''
d_msg_proxy=''
d_msgctl=''
d_msgget=''
d_msghdr_s=''
d_msgrcv=''
d_msgsnd=''
d_msync=''
d_munmap=''
d_mymalloc=''
d_ndbm=''
d_ndbm_h_uses_prototypes=''
d_nice=''
d_nl_langinfo=''
d_nv_preserves_uv='define'
d_nv_zero_is_allbits_zero='define'
d_off64_t=''
d_old_pthread_create_joinable=''
d_oldpthreads=''
d_oldsock=''
d_open3=''
d_pathconf=''
d_pause='define'
d_perl_otherlibdirs=''
d_phostname=''
d_pipe='define'
d_poll=''
d_portable='define'
d_prctl=''
d_prctl_set_name=''
d_printf_format_null=''
d_procselfexe=''
d_pseudofork='define'
d_pthread_atfork=''
d_pthread_attr_setscope=''
d_pthread_yield=''
d_pwage=''
d_pwchange=''
d_pwclass=''
d_pwcomment=''
d_pwexpire=''
d_pwgecos=''
d_pwpasswd=''
d_pwquota=''
d_qgcvt=''
d_quad='define'
d_random_r=''
d_readdir='define'
d_readdir64_r=''
d_readdir_r=''
d_readlink=''
d_readv=''
d_recvmsg=''
d_rename='define'
d_rewinddir='define'
d_rmdir='define'
d_safebcpy=''
d_safemcpy=''
d_sanemcmp='define'
d_sbrkproto=''
d_scalbnl=''
d_sched_yield=''
d_scm_rights=''
d_seekdir='define'
d_select='define'
d_sem=''
d_semctl=''
d_semctl_semid_ds=''
d_semctl_semun=''
d_semget=''
d_semop=''
d_sendmsg=''
d_setegid=''
d_seteuid=''
d_setgrent=''
d_setgrent_r=''
d_setgrps=''
d_sethent=''
d_sethostent_r=''
d_setitimer=''
d_setlinebuf=''
d_setlocale='define'
d_setlocale_r=''
d_setnent=''
d_setnetent_r=''
d_setpent=''
d_setpgid=''
d_setpgrp=''
d_setpgrp2=''
d_setprior=''
d_setproctitle=''
d_setprotoent_r=''
d_setpwent=''
d_setpwent_r=''
d_setregid=''
d_setresgid=''
d_setresuid=''
d_setreuid=''
d_setrgid=''
d_setruid=''
d_setsent=''
d_setservent_r=''
d_setsid=''
d_setvbuf='define'
d_sfio=''
d_shm=''
d_shmat=''
d_shmatprototype=''
d_shmctl=''
d_shmdt=''
d_shmget=''
d_sigaction=''
d_signbit=''
d_sigprocmask=''
d_sigsetjmp=''
d_sin6_scope_id='define'
d_sitearch='define'
d_snprintf='define'
d_sockaddr_in6=''
d_sockaddr_sa_len=''
d_sockatmark=''
d_sockatmarkproto=''
d_socket='define'
d_socklen_t=''
d_sockpair=''
d_socks5_init=''
d_sprintf_returns_strlen='define'
d_sqrtl=''
d_srand48_r=''
d_srandom_r=''
d_sresgproto=''
d_sresuproto=''
d_statblks=''
d_statfs_f_flags=''
d_statfs_s=''
d_static_inline='define'
d_statvfs=''
d_stdio_cnt_lval='define'
d_stdio_ptr_lval='define'
d_stdio_ptr_lval_nochange_cnt='define'
d_stdio_ptr_lval_sets_cnt=''
d_stdio_stream_array=''
d_stdiobase='define'
d_stdstdio='define'
d_strchr='define'
d_strcoll='define'
d_strctcpy='define'
d_strerrm='strerror(e)'
d_strerror='define'
d_strerror_r=''
d_strftime='define'
d_strlcat=''
d_strlcpy=''
d_strtod='define'
d_strtol='define'
d_strtold=''
d_strtoll=''
d_strtoq=''
d_strtoul='define'
d_strtoull=''
d_strtouq=''
d_strxfrm='define'
d_suidsafe=''
d_symlink=''
d_syscall=''
d_syscallproto=''
d_sysconf=''
d_sysernlst=''
d_syserrlst='define'
d_system='define'
d_tcgetpgrp=''
d_tcsetpgrp=''
d_telldir='define'
d_telldirproto='define'
d_time='define'
d_timegm=''
d_times='define'
d_tm_tm_gmtoff=''
d_tm_tm_zone=''
d_tmpnam_r=''
d_truncate=''
d_ttyname_r=''
d_tzname='define'
d_u32align='define'
d_ualarm=''
d_umask='define'
d_uname='define'
d_union_semun='define'
d_unordered=''
d_unsetenv=''
d_usleep=''
d_usleepproto=''
d_ustat=''
d_vendorarch=''
d_vendorbin=''
d_vendorlib=''
d_vendorscript=''
d_vfork=''
d_void_closedir=''
d_voidsig='define'
d_voidtty=''
d_volatile='define'
d_vprintf='define'
d_vsnprintf='define'
d_wait4=''
d_waitpid='define'
d_wcstombs='define'
d_wctomb='define'
d_writev=''
d_xenix=''
date='date'
db_hashtype='int'
db_prefixtype='int'
db_version_major='0'
db_version_minor='0'
db_version_patch='0'
defvoidused='15'
direntrytype='struct direct'
dlext='dll'
dlltool='dlltool'
dlsrc='dl_win32.xs'
doublesize='8'
drand01='(rand()/(double)((unsigned)1<<RANDBITS))'
drand48_r_proto='0'
dtrace=''
dynamic_ext='B Compress/Raw/Bzip2 Compress/Raw/Zlib Cwd Data/Dumper Devel/PPPort Devel/Peek Digest/MD5 Digest/SHA Encode Fcntl File/Glob Filter/Util/Call Hash/Util Hash/Util/FieldHash IO List/Util MIME/Base64 Math/BigInt/FastCalc Opcode POSIX PerlIO/encoding PerlIO/mmap PerlIO/scalar PerlIO/via SDBM_File Socket Storable Sys/Hostname Text/Soundex Tie/Hash/NamedCapture Time/HiRes Time/Piece Unicode/Collate Unicode/Normalize Win32 Win32API/File XS/APItest XS/Typemap arybase attributes mro re threads threads/shared'
eagain='EAGAIN'
ebcdic=''
echo='echo'
egrep='egrep'
emacs=''
endgrent_r_proto='0'
endhostent_r_proto='0'
endnetent_r_proto='0'
endprotoent_r_proto='0'
endpwent_r_proto='0'
endservent_r_proto='0'
eunicefix='​:'
exe_ext='.exe'
expr='expr'
extensions='Archive/Extract Archive/Tar Attribute/Handlers AutoLoader B B/Debug B/Deparse B/Lint CGI CPAN CPAN/Meta CPAN/Meta/YAML CPANPLUS CPANPLUS/Dist/Build Carp Compress/Raw/Bzip2 Compress/Raw/Zlib Cwd Data/Dumper Devel/PPPort Devel/Peek Devel/SelfStubber Digest Digest/MD5 Digest/SHA Dumpvalue Encode Env Errno ExtUtils/CBuilder ExtUtils/Command ExtUtils/Constant ExtUtils/Install ExtUtils/MakeMaker ExtUtils/Manifest ExtUtils/ParseXS Fcntl File/CheckTree File/Fetch File/Glob File/Path File/Temp FileCache Filter/Simple Filter/Util/Call Getopt/Long HTTP/Tiny Hash/Util Hash/Util/FieldHash I18N/Collate I18N/LangTags IO IO/Compress IO/Zlib IPC/Cmd IPC/Open3 JSON/PP List/Util Locale/Codes Locale/Maketext Locale/Maketext/Simple Log/Message Log/Message/Simple MIME/Base64 Math/BigInt Math/BigInt/FastCalc Math/BigRat Math/Complex Memoize Module/Build Module/CoreList Module/Load Module/Load/Conditional Module/Loaded Module/Metadata Module/Pluggable NEXT Net/Ping Object/Accessor Opcode POSIX Package/Constants Params/Check Parse/CPAN/Meta Perl/OSType PerlIO/encoding PerlIO/mmap PerlIO/scalar PerlIO/via PerlIO/via/QuotedPrint Pod/Escapes Pod/Functions Pod/Html Pod/LaTeX Pod/Parser Pod/Perldoc Pod/Simple SDBM_File Safe Search/Dict SelfLoader Socket Storable Sys/Hostname Term/ANSIColor Term/Cap Term/Complete Term/ReadLine Term/UI Test Test/Harness Test/Simple Text/Abbrev Text/Balanced Text/ParseWords Text/Soundex Text/Tabs Thread/Queue Thread/Semaphore Tie/File Tie/Hash/NamedCapture Tie/Memoize Tie/RefHash Time/HiRes Time/Local Time/Piece Unicode/Collate Unicode/Normalize Version/Requirements Win32 Win32API/File Win32CORE XS/APItest XS/Typemap XSLoader arybase attributes autodie autouse base bignum constant encoding/warnings if lib libnet mro parent perlfaq podlators re threads threads/shared'
extern_C='extern'
extras=''
fflushNULL='define'
fflushall=''
find='find'
firstmakefile='makefile'
flex=''
fpossize='8'
fpostype='fpos_t'
freetype='void'
from='​:'
full_ar=''
full_csh=''
full_sed=''
gccansipedantic=''
gccosandvers=''
gccversion=''
getgrent_r_proto='0'
getgrgid_r_proto='0'
getgrnam_r_proto='0'
gethostbyaddr_r_proto='0'
gethostbyname_r_proto='0'
gethostent_r_proto='0'
getlogin_r_proto='0'
getnetbyaddr_r_proto='0'
getnetbyname_r_proto='0'
getnetent_r_proto='0'
getprotobyname_r_proto='0'
getprotobynumber_r_proto='0'
getprotoent_r_proto='0'
getpwent_r_proto='0'
getpwnam_r_proto='0'
getpwuid_r_proto='0'
getservbyname_r_proto='0'
getservbyport_r_proto='0'
getservent_r_proto='0'
getspnam_r_proto='0'
gidformat='"ld"'
gidsign='-1'
gidsize='4'
gidtype='gid_t'
git_branch=''
git_commit_id=''
git_commit_id_title=''
git_describe=''
git_uncommitted_changes=''
glibpth='/usr/shlib /lib/pa1.1 /usr/lib/large /lib /usr/lib /usr/lib/386 /lib/386 /lib/large /usr/lib/small /lib/small /usr/ccs/lib /usr/ucblib /usr/shlib '
gmake='gmake'
gmtime_r_proto='0'
gnulibc_version=''
grep='grep'
groupcat=''
groupstype='gid_t'
gzip='gzip'
h_fcntl='false'
h_sysfile='true'
hint='recommended'
hostcat='ypcat hosts'
html1dir=' '
html1direxp=''
html3dir=' '
html3direxp=''
i16size='2'
i16type='short'
i32size='4'
i32type='long'
i64size='8'
i64type='__int64'
i8size='1'
i8type='char'
i_arpainet='define'
i_assert='define'
i_bsdioctl=''
i_crypt=''
i_db=''
i_dbm=''
i_dirent='define'
i_dld=''
i_dlfcn='define'
i_fcntl='define'
i_float='define'
i_fp=''
i_fp_class=''
i_gdbm=''
i_gdbm_ndbm=''
i_gdbmndbm=''
i_grp=''
i_ieeefp=''
i_inttypes=''
i_langinfo=''
i_libutil=''
i_limits='define'
i_locale='define'
i_machcthr=''
i_malloc='define'
i_mallocmalloc=''
i_math='define'
i_memory=''
i_mntent=''
i_ndbm=''
i_netdb=''
i_neterrno=''
i_netinettcp=''
i_niin=''
i_poll=''
i_prot=''
i_pthread=''
i_pwd=''
i_rpcsvcdbm='define'
i_sfio=''
i_sgtty=''
i_shadow=''
i_socks=''
i_stdarg='define'
i_stdbool=''
i_stddef='define'
i_stdlib='define'
i_string='define'
i_sunmath=''
i_sysaccess=''
i_sysdir=''
i_sysfile=''
i_sysfilio='define'
i_sysin=''
i_sysioctl=''
i_syslog=''
i_sysmman=''
i_sysmode=''
i_sysmount=''
i_sysndir=''
i_sysparam=''
i_syspoll=''
i_sysresrc=''
i_syssecrt=''
i_sysselct=''
i_syssockio=''
i_sysstat='define'
i_sysstatfs=''
i_sysstatvfs=''
i_systime=''
i_systimek=''
i_systimes=''
i_systypes='define'
i_sysuio=''
i_sysun=''
i_sysutsname=''
i_sysvfs=''
i_syswait=''
i_termio=''
i_termios=''
i_time='define'
i_unistd=''
i_ustat=''
i_utime='define'
i_values=''
i_varargs=''
i_varhdr='varargs.h'
i_vfork=''
ignore_versioned_solibs=''
inc_version_list=''
inc_version_list_init='0'
incpath='\include'
inews=''
initialinstalllocation=''
installarchlib='D​:\Perl\lib'
installbin='D​:\Perl\bin'
installhtml1dir=''
installhtml3dir=''
installhtmldir='D​:\Perl\html'
installhtmlhelpdir='D​:\Perl\htmlhelp'
installman1dir='D​:\Perl\man\man1'
installman3dir='D​:\Perl\man\man3'
installprefix='D​:\Perl'
installprefixexp='D​:\Perl'
installprivlib='D​:\Perl\lib'
installscript='D​:\Perl\bin'
installsitearch='D​:\Perl\site\lib'
installsitebin='D​:\Perl\site\bin'
installsitehtml1dir=''
installsitehtml3dir=''
installsitelib='D​:\Perl\site\lib'
installsiteman1dir=''
installsiteman3dir=''
installsitescript='D​:\Perl\site\bin'
installstyle='lib'
installusrbinperl=''
installvendorarch=''
installvendorbin=''
installvendorhtml1dir=''
installvendorhtml3dir=''
installvendorlib=''
installvendorman1dir=''
installvendorman3dir=''
installvendorscript=''
intsize='4'
issymlink=''
ivdformat='"ld"'
ivsize='4'
ivtype='long'
known_extensions='B Compress/Raw/Bzip2 Compress/Raw/Zlib Cwd DB_File Data/Dumper Devel/PPPort Devel/Peek Digest/MD5 Digest/SHA Encode Fcntl File/Glob Filter/Util/Call GDBM_File Hash/Util Hash/Util/FieldHash I18N/Langinfo IO IPC/SysV List/Util MIME/Base64 Math/BigInt/FastCalc NDBM_File ODBM_File Opcode POSIX PerlIO/encoding PerlIO/mmap PerlIO/scalar PerlIO/via SDBM_File Socket Storable Sys/Hostname Sys/Syslog Text/Soundex Tie/Hash/NamedCapture Time/HiRes Time/Piece Unicode/Collate Unicode/Normalize VMS/DCLsym VMS/Stdio Win32 Win32API/File Win32CORE XS/APItest XS/Typemap arybase attributes mro re threads threads/shared'
ksh=''
ld='link'
lddlflags='-dll -nologo -nodefaultlib -debug -opt​:ref,icf -libpath​:"D​:\Perl\lib\CORE" -machine​:x86'
ldflags='-nologo -nodefaultlib -debug -opt​:ref,icf -libpath​:"D​:\Perl\lib\CORE" -machine​:x86'
ldflags_nolargefiles='-nologo -nodefaultlib -debug -opt​:ref,icf -libpath​:"D​:\Perl\lib\CORE" -machine​:x86'
ldflags_uselargefiles=''
ldlibpthname=''
less='less'
lib_ext='.lib'
libc='msvcrt.lib'
libperl='perl516.lib'
libpth='\lib'
libs='oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib'
libs_nolargefiles=''
libsdirs=''
libsfiles=''
libsfound=''
libspath=''
libswanted='net socket inet nsl nm ndbm gdbm dbm db malloc dl dld ld sun m c cposix posix ndir dir crypt ucb bsd BSD PW x'
libswanted_nolargefiles=''
libswanted_uselargefiles='net socket inet nsl nm ndbm gdbm dbm db malloc dl dld ld sun m c cposix posix ndir dir crypt ucb bsd BSD PW x'
line='line'
lint=''
lkflags=''
ln=''
lns='copy'
localtime_r_proto='0'
locincpth='/usr/local/include /opt/local/include /usr/gnu/include /opt/gnu/include /usr/GNU/include /opt/GNU/include'
loclibpth='/usr/local/lib /opt/local/lib /usr/gnu/lib /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib'
longdblsize='8'
longlongsize='8'
longsize='4'
lp=''
lpr=''
ls='dir'
lseeksize='8'
lseektype='__int64'
mad=''
madlyh=''
madlyobj=''
madlysrc=''
mail=''
mailx=''
make='C​:\PROGRA1\MICROS3\VC98\bin\nmake.exe'
make_set_make='#'
mallocobj='malloc.o'
mallocsrc='malloc.c'
malloctype='void *'
man1dir='D​:\Perl\man\man1'
man1direxp='D​:\Perl\man\man1'
man1ext='1'
man3dir='D​:\Perl\man\man3'
man3direxp='D​:\Perl\man\man3'
man3ext='3'
mips_type=''
mistrustnm=''
mkdir='mkdir'
mmaptype='void *'
modetype='mode_t'
more='more /e'
multiarch=''
mv=''
myarchname='MSWin32'
mydomain=''
myhostname=''
myuname=''
n='-n'
need_va_copy=''
netdb_hlen_type='int'
netdb_host_type='char *'
netdb_name_type='char *'
netdb_net_type='long'
nm=''
nm_opt=''
nm_so_opt=''
nonxs_ext='Archive/Extract Archive/Tar Attribute/Handlers AutoLoader B/Debug B/Deparse B/Lint CGI CPAN CPAN/Meta CPAN/Meta/YAML CPANPLUS CPANPLUS/Dist/Build Carp Devel/SelfStubber Digest Dumpvalue Env Errno ExtUtils/CBuilder ExtUtils/Command ExtUtils/Constant ExtUtils/Install ExtUtils/MakeMaker ExtUtils/Manifest ExtUtils/ParseXS File/CheckTree File/Fetch File/Path File/Temp FileCache Filter/Simple Getopt/Long HTTP/Tiny I18N/Collate I18N/LangTags IO/Compress IO/Zlib IPC/Cmd IPC/Open3 JSON/PP Locale/Codes Locale/Maketext Locale/Maketext/Simple Log/Message Log/Message/Simple Math/BigInt Math/BigRat Math/Complex Memoize Module/Build Module/CoreList Module/Load Module/Load/Conditional Module/Loaded Module/Metadata Module/Pluggable NEXT Net/Ping Object/Accessor Package/Constants Params/Check Parse/CPAN/Meta Perl/OSType PerlIO/via/QuotedPrint Pod/Escapes Pod/Functions Pod/Html Pod/LaTeX Pod/Parser Pod/Perldoc Pod/Simple Safe Search/Dict SelfLoader Term/ANSIColor Term/Cap Term/Complete Term/ReadLine Term/UI Test Test/Harness Test/Simple Text/Abbrev Text/Balanced Text/ParseWords Text/Tabs Thread/Queue Thread/Semaphore Tie/File Tie/Memoize Tie/RefHash Time/Local Version/Requirements XSLoader autodie autouse base bignum constant encoding/warnings if lib libnet parent perlfaq podlators'
nroff=''
nvEUformat='"E"'
nvFUformat='"F"'
nvGUformat='"G"'
nv_overflows_integers_at='256.0*256.0*256.0*256.0*256.0*256.0*2.0*2.0*2.0*2.0*2.0'
nv_preserves_uv_bits='32'
nveformat='"e"'
nvfformat='"f"'
nvgformat='"g"'
nvsize='8'
nvtype='double'
o_nonblock='O_NONBLOCK'
obj_ext='.obj'
old_pthread_create_joinable=''
optimize='-MD -Zi -DNDEBUG -O1'
orderlib='false'
osname='MSWin32'
osvers='5.2'
otherlibdirs=''
package='perl5'
pager='more /e'
passcat=''
patchlevel='16'
path_sep=';'
perl='perl'
perl5=''
perl_patchlevel=''
perl_static_inline='static __inline'
perladmin=''
perllibs='oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib'
perlpath='D​:\Perl\bin\perl.exe'
pg=''
phostname='hostname'
pidtype='int'
plibpth=''
pmake=''
ppmarch='MSWin32-x86'
pr=''
prefix='D​:\Perl'
prefixexp='D​:\Perl'
privlib='D​:\Perl\lib'
privlibexp='D​:\Perl\lib'
procselfexe=''
prototype='define'
ptrsize='4'
quadkind='5'
quadtype='__int64'
randbits='15'
randfunc='rand'
random_r_proto='0'
randseedtype='unsigned'
ranlib='rem'
rd_nodata='-1'
readdir64_r_proto='0'
readdir_r_proto='0'
revision='5'
rm='del'
rm_try=''
rmail=''
run=''
runnm='true'
sGMTIME_max='2147483647'
sGMTIME_min='0'
sLOCALTIME_max='2147483647'
sLOCALTIME_min='0'
sPRIEUldbl='"E"'
sPRIFUldbl='"F"'
sPRIGUldbl='"G"'
sPRIXU64='"lX"'
sPRId64='"ld"'
sPRIeldbl='"e"'
sPRIfldbl='"f"'
sPRIgldbl='"g"'
sPRIi64='"li"'
sPRIo64='"lo"'
sPRIu64='"lu"'
sPRIx64='"lx"'
sSCNfldbl='"f"'
sched_yield=''
scriptdir='D​:\Perl\bin'
scriptdirexp='D​:\Perl\bin'
sed='sed'
seedfunc='srand'
selectminbits='32'
selecttype='Perl_fd_set *'
sendmail='blat'
setgrent_r_proto='0'
sethostent_r_proto='0'
setlocale_r_proto='0'
setnetent_r_proto='0'
setprotoent_r_proto='0'
setpwent_r_proto='0'
setservent_r_proto='0'
sh='cmd /x /c'
shar=''
sharpbang='#!'
shmattype='void *'
shortsize='2'
shrpenv=''
shsharp='true'
sig_count='26'
sig_name='ZERO HUP INT QUIT ILL NUM05 NUM06 NUM07 FPE KILL NUM10 SEGV NUM12 PIPE ALRM TERM NUM16 NUM17 NUM18 NUM19 CHLD BREAK ABRT STOP NUM24 CONT CLD'
sig_name_init='"ZERO", "HUP", "INT", "QUIT", "ILL", "NUM05", "NUM06", "NUM07", "FPE", "KILL", "NUM10", "SEGV", "NUM12", "PIPE", "ALRM", "TERM", "NUM16", "NUM17", "NUM18", "NUM19", "CHLD", "BREAK", "ABRT", "STOP", "NUM24", "CONT", "CLD", 0'
sig_num='0 1 2 21 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 20'
sig_num_init='0, 1, 2, 21, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 20, 0'
sig_size='27'
signal_t='void'
sitearch='D​:\Perl\site\lib'
sitearchexp='D​:\Perl\site\lib'
sitebin='D​:\Perl\site\bin'
sitebinexp='D​:\Perl\site\bin'
sitehtml1dir=''
sitehtml1direxp=''
sitehtml3dir=''
sitehtml3direxp=''
sitelib='D​:\Perl\site\lib'
sitelib_stem=''
sitelibexp='D​:\Perl\site\lib'
siteman1dir=''
siteman1direxp=''
siteman3dir=''
siteman3direxp=''
siteprefix='D​:\Perl\site'
siteprefixexp='D​:\Perl\site'
sitescript=''
sitescriptexp=''
sizesize='4'
sizetype='size_t'
sleep=''
smail=''
so='dll'
sockethdr=''
socketlib=''
socksizetype='int'
sort='sort'
spackage='Perl5'
spitshell=''
srand48_r_proto='0'
srandom_r_proto='0'
src=''
ssizetype='int'
st_ino_sign='1'
st_ino_size='4'
startperl='#!perl'
startsh='#!/bin/sh'
static_ext='Win32CORE'
stdchar='char'
stdio_base='((fp)->_base)'
stdio_bufsiz='((fp)->_cnt + (fp)->_ptr - (fp)->_base)'
stdio_cnt='((fp)->_cnt)'
stdio_filbuf=''
stdio_ptr='((fp)->_ptr)'
stdio_stream_array=''
strerror_r_proto='0'
strings='/usr/include/string.h'
submit=''
subversion=''
sysman='/usr/man/man1'
tail=''
tar=''
targetarch=''
tbl=''
tee=''
test=''
timeincl='/usr/include/sys/time.h '
timetype='time_t'
tmpnam_r_proto='0'
to='​:'
touch='touch'
tr=''
trnl='\012'
troff=''
ttyname_r_proto='0'
u16size='2'
u16type='unsigned short'
u32size='4'
u32type='unsigned long'
u64size='8'
u64type='unsigned __int64'
u8size='1'
u8type='unsigned char'
uidformat='"ld"'
uidsign='-1'
uidsize='4'
uidtype='uid_t'
uname='uname'
uniq='uniq'
uquadtype='unsigned __int64'
use5005threads=''
use64bitall=''
use64bitint=''
usecrosscompile=''
usedevel=''
usedl='define'
usedtrace=''
usefaststdio=''
useithreads='define'
usekernprocpathname=''
uselargefiles='define'
uselongdouble=''
usemallocwrap='define'
usemorebits=''
usemultiplicity='define'
usemymalloc='n'
usenm='false'
usensgetexecutablepath=''
useopcode='true'
useperlio='define'
useposix='true'
usereentrant=''
userelocatableinc=''
usesfio='false'
useshrplib='true'
usesitecustomize='define'
usesocks=''
usethreads='define'
usevendorprefix=''
usevfork='false'
usrinc='/usr/include'
uuname=''
uvXUformat='"lX"'
uvoformat='"lo"'
uvsize='4'
uvtype='unsigned long'
uvuformat='"lu"'
uvxformat='"lx"'
vaproto=''
vendorarch=''
vendorarchexp=''
vendorbin=''
vendorbinexp=''
vendorhtml1dir=' '
vendorhtml1direxp=''
vendorhtml3dir=' '
vendorhtml3direxp=''
vendorlib=''
vendorlib_stem=''
vendorlibexp=''
vendorman1dir=' '
vendorman1direxp=''
vendorman3dir=' '
vendorman3direxp=''
vendorprefix=''
vendorprefixexp=''
vendorscript=''
vendorscriptexp=''
version='5.16.3'
version_patchlevel_string='version 16 subversion 3'
versiononly=''
vi=''
voidflags='15'
xlibpth='/usr/lib/386 /lib/386'
yacc='yacc'
yaccflags=''
zcat=''
zip='zip'

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Nov 23, 2014

From @pjcj

Created by @pjcj

This is a bug report for perl from paul@​pjcj.net,
generated with the help of perlbug 1.40 running under perl 5.20.1.

-----------------------------------------------------------------

Here's a lovely bug found by Stanislaw Romanski and reported on LinkedIn.

$ perl -e 'map { for (my $i = 0; $i < 3; $i++) { push @​a, $_ } } a..e; print join("", @​a)'
aaa333012dddeee

It worked in 5.6.* and is broken in 5.8.0. Specifically, it broke in 36c6672​:

commit 36c6672
Author​: Robin Houston <robin@​cpan.org>
Date​: Wed Mar 14 00​:43​:45 2001 +0000

  Re​: [ID 20010309.004] my-variables lose values while goto'ing within a for(;;)-loop
  Message-ID​: <20010314004345.A15892@​puffinry.freeserve.co.uk>

  p4raw-id​: //depot/perl@​9139

The commit was identified with​:

$ ../perl-bisect/Porting/bisect.pl --end=perl-5.8.0 -- ./perl -e 'map { for (my $i = 0; $i < 3; $i++) { push @​a, $_ } } a..e; exit 0+!(jonn("", @​a) eq "aaabbbcccdddeee")'

For completeness, the original message is at
https://www.linkedin.com/groupItem?view=&gid=106254&type=member&item=5942368474230718468D
but you probably have to be logged in to LinkedIn and be a member of the Perl
group to see that.

Perl Info

Flags:
    category=core
    severity=medium

Site configuration information for perl 5.20.1:

Configured by pjcj at Sun Oct 19 17:08:42 CEST 2014.

Summary of my perl5 (revision 5 version 20 subversion 1) configuration:
   
  Platform:
    osname=linux, osvers=3.13.0-37-generic, archname=x86_64-linux
    uname='linux posub64 3.13.0-37-generic #64-ubuntu smp mon sep 22 21:28:38 utc 2014 x86_64 x86_64 x86_64 gnulinux '
    config_args='-de -Dprefix=/home/pjcj/perl5/perlbrew/perls/perl-5.20.1 -Aeval:scriptdir=/home/pjcj/perl5/perlbrew/perls/perl-5.20.1/bin'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.8.2', 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 =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.19'
  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'



@INC for perl 5.20.1:
    /home/pjcj/perl5/perlbrew/perls/perl-5.20.1/lib/site_perl/5.20.1/x86_64-linux
    /home/pjcj/perl5/perlbrew/perls/perl-5.20.1/lib/site_perl/5.20.1
    /home/pjcj/perl5/perlbrew/perls/perl-5.20.1/lib/5.20.1/x86_64-linux
    /home/pjcj/perl5/perlbrew/perls/perl-5.20.1/lib/5.20.1
    .


Environment for perl 5.20.1:
    HOME=/home/pjcj
    LANG=en_GB.UTF-8
    LANGUAGE=en_GB:en
    LC_COLLATE=en_GB.UTF-8
    LC_CTYPE=en_GB.UTF-8
    LC_MESSAGES=en_GB.UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/pjcj/perl5/perlbrew/bin:/home/pjcj/perl5/perlbrew/perls/perl-5.20.1/bin:/home/pjcj/bin:/home/pjcj/g/local_base/utils:/home/pjcj/g/base/utils:/home/pjcj/g/sw/bin:/home/pjcj/g/sw/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/pjcj/.local/bin
    PERLBREW=command perlbrew
    PERLBREW_BASHRC_VERSION=0.71
    PERLBREW_HOME=/home/pjcj/.perlbrew
    PERLBREW_MANPATH=/home/pjcj/perl5/perlbrew/perls/perl-5.20.1/man
    PERLBREW_PATH=/home/pjcj/perl5/perlbrew/bin:/home/pjcj/perl5/perlbrew/perls/perl-5.20.1/bin
    PERLBREW_PERL=perl-5.20.1
    PERLBREW_ROOT=/home/pjcj/perl5/perlbrew
    PERLBREW_VERSION=0.71
    PERL_BADLANG (unset)
    SHELL=/bin/zsh

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Nov 24, 2014

From @cpansprout

On Sun Nov 23 15​:22​:09 2014, paul@​pjcj.net wrote​:

This is a bug report for perl from paul@​pjcj.net,
generated with the help of perlbug 1.40 running under perl 5.20.1.

-----------------------------------------------------------------

Here's a lovely bug found by Stanislaw Romanski and reported on
LinkedIn.

$ perl -e 'map { for (my $i = 0; $i < 3; $i++) { push @​a, $_ } } a..e;
print join("", @​a)'
aaa333012dddeee

It worked in 5.6.* and is broken in 5.8.0.

The really weird thing is that ${\$_} just works.

--

Father Chrysostomos

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Nov 24, 2014

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

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Nov 24, 2014

From @pjcj

This should be merged with 123285, which is Stanislaw's own report which
was probably in moderation when I made this report. Sorry about that.

--
Paul Johnson - paul@​pjcj.net
http​://www.pjcj.net

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Nov 24, 2014

From @davidnicol

Perlsyn's section on C-style "for" loops does not mention aliasing $_ at
all, and when the topic
is simply mentioned prior to the loop, in 5.8.8, the bug disappears. This
sure is screwy, how the behavior is right the first time, wrong the second,
wrong in a different way the third, then back to right.

$ perl -le 'map { for (my $i = 0; $i < 3; $i++) { push @​a, $_ } } a..e;
print join("", @​a)'
aaa333012dddeee
$ perl -le 'map { $_; for (my $i = 0; $i < 3; $i++) { push @​a, $_ } } a..e;
print join("", @​a)'
aaabbbcccdddeee

On Mon, Nov 24, 2014 at 4​:21 AM, Paul Johnson <paul@​pjcj.net> wrote​:

This should be merged with 123285, which is Stanislaw's own report which
was probably in moderation when I made this report. Sorry about that.

--
Paul Johnson - paul@​pjcj.net
http​://www.pjcj.net

--
Sometimes I imply things, or include important information in pictures.
Without a request for clarification, I will assume I was clear, which can
cause later problems when I wasn't. So please ask me to clarify anything
that seems ambiguous. Doing so is not rude. Thank you.

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Nov 24, 2014

From @ilmari

David Nicol <davidnicol@​gmail.com> writes​:

Perlsyn's section on C-style "for" loops does not mention aliasing $_
at all, and when the topic is simply mentioned prior to the loop, in
5.8.8, the bug disappears.

It doesn't even have to be the topic. Any variable (global or lexical)
will do.

This sure is screwy, how the behavior is right the first time, wrong
the second, wrong in a different way the third, then back to right.

$ perl -le 'map { for (my $i = 0; $i < 3; $i++) { push @​a, $_ } } a..e;
print join("", @​a)'
aaa333012dddeee
$ perl -le 'map { $_; for (my $i = 0; $i < 3; $i++) { push @​a, $_ } } a..e;
print join("", @​a)'
aaabbbcccdddeee

perl -le 'map { $foo; for (my $i = 0; $i < 3; $i++) { push @​a, $_ } } a..e; print @​a'
aaabbbcccdddeee
perl -le 'map { my $foo; for (my $i = 0; $i < 3; $i++) { push @​a, $_ } } a..e; print @​a'
aaabbbcccdddeee
perl -le 'map { our $foo; for (my $i = 0; $i < 3; $i++) { push @​a, $_ } } a..e; print @​a'
aaabbbcccdddeee

On Mon, Nov 24, 2014 at 4​:21 AM, Paul Johnson <paul@​pjcj.net> wrote​:

This should be merged with 123285, which is Stanislaw's own report which
was probably in moderation when I made this report. Sorry about that.

--
Paul Johnson - paul@​pjcj.net
http​://www.pjcj.net

--
"A disappointingly low fraction of the human race is,
at any given time, on fire." - Stig Sandbeck Mathisen

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Nov 24, 2014

From @cpansprout

On Mon Nov 24 11​:01​:51 2014, ilmari wrote​:

David Nicol <davidnicol@​gmail.com> writes​:

Perlsyn's section on C-style "for" loops does not mention aliasing $_
at all, and when the topic is simply mentioned prior to the loop, in
5.8.8, the bug disappears.

It doesn't even have to be the topic. Any variable (global or lexical)
will do.

This sure is screwy, how the behavior is right the first time, wrong
the second, wrong in a different way the third, then back to right.

$ perl -le 'map { for (my $i = 0; $i < 3; $i++) { push @​a, $_ } }
a..e;
print join("", @​a)'
aaa333012dddeee
$ perl -le 'map { $_; for (my $i = 0; $i < 3; $i++) { push @​a, $_ } }
a..e;
print join("", @​a)'
aaabbbcccdddeee

perl -le 'map { $foo; for (my $i = 0; $i < 3; $i++) { push @​a, $_ } }
a..e; print @​a'
aaabbbcccdddeee
perl -le 'map { my $foo; for (my $i = 0; $i < 3; $i++) { push @​a, $_ }
} a..e; print @​a'
aaabbbcccdddeee
perl -le 'map { our $foo; for (my $i = 0; $i < 3; $i++) { push @​a, $_
} } a..e; print @​a'
aaabbbcccdddeee

This smells like a stack bug. I suspect the key is that the for loop must be the only thing inside the map block and there must be only one statement inside the for loop. New statements generally reset the stack, but things may get screwy at the beginning of a scope.

--

Father Chrysostomos

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Nov 24, 2014

From @ikegami

On Mon, Nov 24, 2014 at 1​:46 PM, David Nicol <davidnicol@​gmail.com> wrote​:

Perlsyn's section on C-style "for" loops does not mention aliasing $_ at
all, and when the topic
is simply mentioned prior to the loop, in 5.8.8, the bug disappears.

Placing a statement before the for also makes the weirdness disappear.

$ perl -le 'map { for (my $i = 0; $i < 3; $i++) { push @​a, $_ } } a..e;
print join("", @​a)'
aaa333012dddeee

# Statement before
$ perl -le 'map { ""; for (my $i = 0; $i < 3; $i++) { push @​a, $_ } } a..e;
print join("", @​a)'
aaabbbcccdddeee

# $_ outside of for
$ perl -le 'map { for (my $i = 0; $i < 3; $i++) { push @​a, $_ } $_ } a..e;
print join("", @​a)'
aaabbbcccdddeee

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Nov 24, 2014

From @ikegami

On Mon, Nov 24, 2014 at 3​:04 PM, Eric Brine <ikegami@​adaelis.com> wrote​:

On Mon, Nov 24, 2014 at 1​:46 PM, David Nicol <davidnicol@​gmail.com> wrote​:

Perlsyn's section on C-style "for" loops does not mention aliasing $_ at
all, and when the topic
is simply mentioned prior to the loop, in 5.8.8, the bug disappears.

Placing a statement before the for also makes the weirdness disappear.

$ perl -le 'map { for (my $i = 0; $i < 3; $i++) { push @​a, $_ } } a..e;
print join("", @​a)'
aaa333012dddeee

# Statement before
$ perl -le 'map { ""; for (my $i = 0; $i < 3; $i++) { push @​a, $_ } }
a..e; print join("", @​a)'
aaabbbcccdddeee

# $_ outside of for
$ perl -le 'map { for (my $i = 0; $i < 3; $i++) { push @​a, $_ } $_ } a..e;
print join("", @​a)'
aaabbbcccdddeee

Correction, any other statement, before or after, makes the problem go away.

$ perl -le 'map { for (my $i = 0; $i < 3; $i++) { push @​a, $_ } } a..e;
print join("", @​a)'
aaa333012dddeee

# Statement before
$ perl -le 'map { ""; for (my $i = 0; $i < 3; $i++) { push @​a, $_ } } a..e;
print join("", @​a)'
aaabbbcccdddeee

# Statement after
$ perl -le 'map { for (my $i = 0; $i < 3; $i++) { push @​a, $_ } "" } a..e;
print join("", @​a)'
aaabbbcccdddeee

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Nov 26, 2014

From @cpansprout

On Mon Nov 24 12​:06​:46 2014, ikegami@​adaelis.com wrote​:

On Mon, Nov 24, 2014 at 3​:04 PM, Eric Brine <ikegami@​adaelis.com> wrote​:

On Mon, Nov 24, 2014 at 1​:46 PM, David Nicol <davidnicol@​gmail.com> wrote​:

Perlsyn's section on C-style "for" loops does not mention aliasing $_ at
all, and when the topic
is simply mentioned prior to the loop, in 5.8.8, the bug disappears.

Placing a statement before the for also makes the weirdness disappear.

$ perl -le 'map { for (my $i = 0; $i < 3; $i++) { push @​a, $_ } } a..e;
print join("", @​a)'
aaa333012dddeee

# Statement before
$ perl -le 'map { ""; for (my $i = 0; $i < 3; $i++) { push @​a, $_ } }
a..e; print join("", @​a)'
aaabbbcccdddeee

# $_ outside of for
$ perl -le 'map { for (my $i = 0; $i < 3; $i++) { push @​a, $_ } $_ } a..e;
print join("", @​a)'
aaabbbcccdddeee

Correction, any other statement, before or after, makes the problem go away.

$ perl -le 'map { for (my $i = 0; $i < 3; $i++) { push @​a, $_ } } a..e;
print join("", @​a)'
aaa333012dddeee

# Statement before
$ perl -le 'map { ""; for (my $i = 0; $i < 3; $i++) { push @​a, $_ } } a..e;
print join("", @​a)'
aaabbbcccdddeee

# Statement after
$ perl -le 'map { for (my $i = 0; $i < 3; $i++) { push @​a, $_ } "" } a..e;
print join("", @​a)'
aaabbbcccdddeee

The extra statements seem to be correcting the stack bug. It seems that the for-loop is using the wrong stack offset and stomping on the arguments to map.

The ‘333’ in the output is the constant 3 in $i<3. The ‘012’ is $i.

If I add the following code to pp.c​:pp_study​:

Perl_warn(aTHX_ "stack %d", PL_stack_sp-PL_stack_base);
Perl_warn(aTHX_ "markstack %d", PL_markstack_ptr-PL_markstack);
Perl_warn(aTHX_ "arg is %"SVf", defsv is %"SVf, sv, DEFSV);

Then I see a stack offset of 6 with multiple statements​:

$ ./miniperl -le 'map { for (my $i = 0; $i < 3; $i++) { study $_; }; () } a..e; print join(" ", @​a)'
stack 6 at -e line 1.
markstack 4 at -e line 1.
arg is a, defsv is a at -e line 1.
...

Take away that empty list​:

$ ./miniperl -le 'map { for (my $i = 0; $i < 3; $i++) { study $_; }; } a..e; print join(" ", @​a)'
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is a, defsv is a at -e line 1.
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is a, defsv is a at -e line 1.
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is a, defsv is a at -e line 1.
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is 3, defsv is 3 at -e line 1.
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is 3, defsv is 3 at -e line 1.
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is 3, defsv is 3 at -e line 1.

The stack offset of 1 is now pointing to one of map’s arguments.

--

Father Chrysostomos

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Nov 26, 2014

From @cpansprout

On Tue Nov 25 16​:54​:17 2014, sprout wrote​:

The extra statements seem to be correcting the stack bug. It seems
that the for-loop is using the wrong stack offset and stomping on the
arguments to map.

The ‘333’ in the output is the constant 3 in $i<3. The ‘012’ is $i.

If I add the following code to pp.c​:pp_study​:

Perl_warn(aTHX_ "stack %d", PL_stack_sp-PL_stack_base);
Perl_warn(aTHX_ "markstack %d", PL_markstack_ptr-PL_markstack);
Perl_warn(aTHX_ "arg is %"SVf", defsv is %"SVf, sv, DEFSV);

Then I see a stack offset of 6 with multiple statements​:

$ ./miniperl -le 'map { for (my $i = 0; $i < 3; $i++) { study $_; };
() } a..e; print join(" ", @​a)'
stack 6 at -e line 1.
markstack 4 at -e line 1.
arg is a, defsv is a at -e line 1.
...

Take away that empty list​:

$ ./miniperl -le 'map { for (my $i = 0; $i < 3; $i++) { study $_; }; }
a..e; print join(" ", @​a)'
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is a, defsv is a at -e line 1.
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is a, defsv is a at -e line 1.
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is a, defsv is a at -e line 1.
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is 3, defsv is 3 at -e line 1.
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is 3, defsv is 3 at -e line 1.
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is 3, defsv is 3 at -e line 1.

The stack offset of 1 is now pointing to one of map’s arguments.

Found the bug. I’ll put the details in the commit message. Here is another instance of it​:

$ perl5.20.1 -le 'print 1..3, do{for(0;0;){}}, 4..6;'
0456

--

Father Chrysostomos

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Nov 26, 2014

From @cpansprout

On Tue Nov 25 17​:08​:29 2014, sprout wrote​:

On Tue Nov 25 16​:54​:17 2014, sprout wrote​:

The extra statements seem to be correcting the stack bug. It seems
that the for-loop is using the wrong stack offset and stomping on the
arguments to map.

The ‘333’ in the output is the constant 3 in $i<3. The ‘012’ is $i.

If I add the following code to pp.c​:pp_study​:

Perl_warn(aTHX_ "stack %d", PL_stack_sp-PL_stack_base);
Perl_warn(aTHX_ "markstack %d", PL_markstack_ptr-PL_markstack);
Perl_warn(aTHX_ "arg is %"SVf", defsv is %"SVf, sv, DEFSV);

Then I see a stack offset of 6 with multiple statements​:

$ ./miniperl -le 'map { for (my $i = 0; $i < 3; $i++) { study $_; };
() } a..e; print join(" ", @​a)'
stack 6 at -e line 1.
markstack 4 at -e line 1.
arg is a, defsv is a at -e line 1.
...

Take away that empty list​:

$ ./miniperl -le 'map { for (my $i = 0; $i < 3; $i++) { study $_; };
}
a..e; print join(" ", @​a)'
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is a, defsv is a at -e line 1.
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is a, defsv is a at -e line 1.
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is a, defsv is a at -e line 1.
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is 3, defsv is 3 at -e line 1.
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is 3, defsv is 3 at -e line 1.
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is 3, defsv is 3 at -e line 1.

The stack offset of 1 is now pointing to one of map’s arguments.

Found the bug. I’ll put the details in the commit message.

See <http​://perl5.git.perl.org/perl.git/commitdiff/0f602692a>.

--

Father Chrysostomos

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Nov 26, 2014

@cpansprout - Status changed from 'open' to 'pending release'

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Nov 26, 2014

From @pjcj

On Tue, Nov 25, 2014 at 08​:12​:10PM -0800, Father Chrysostomos via RT wrote​:

On Tue Nov 25 17​:08​:29 2014, sprout wrote​:

Found the bug. I’ll put the details in the commit message.

See <http​://perl5.git.perl.org/perl.git/commitdiff/0f602692a>.

Thanks!

--
Paul Johnson - paul@​pjcj.net
http​://www.pjcj.net

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Nov 27, 2014

From @stas53

Hello Father Chrysostomos,

Thanks for fixing a bug and for a clear explanation of the case
you gave in the commit.

I am proud I could point out a bug lasting about 12 years
in the interpreter of my favourite language ;-))

We had had a long discussion about this case
in Linkedin' group 'Perl'.

Thank you again and Good Luck !

Dr. Stanislaw Romanski

----- Original Message -----
From​: "Father Chrysostomos via RT" <perlbug-followup@​perl.org>
To​: <paul@​pjcj.net>; <s.romanski@​datos.pl>
Sent​: Wednesday, November 26, 2014 5​:12 AM
Subject​: [perl #123286] $_ incorrect within for loop inside map

On Tue Nov 25 17​:08​:29 2014, sprout wrote​:

On Tue Nov 25 16​:54​:17 2014, sprout wrote​:

The extra statements seem to be correcting the stack bug. It seems
that the for-loop is using the wrong stack offset and stomping on the
arguments to map.

The ‘333’ in the output is the constant 3 in $i<3. The ‘012’ is $i.

If I add the following code to pp.c​:pp_study​:

Perl_warn(aTHX_ "stack %d", PL_stack_sp-PL_stack_base);
Perl_warn(aTHX_ "markstack %d", PL_markstack_ptr-PL_markstack);
Perl_warn(aTHX_ "arg is %"SVf", defsv is %"SVf, sv, DEFSV);

Then I see a stack offset of 6 with multiple statements​:

$ ./miniperl -le 'map { for (my $i = 0; $i < 3; $i++) { study $_; };
() } a..e; print join(" ", @​a)'
stack 6 at -e line 1.
markstack 4 at -e line 1.
arg is a, defsv is a at -e line 1.
...

Take away that empty list​:

$ ./miniperl -le 'map { for (my $i = 0; $i < 3; $i++) { study $_; };
}
a..e; print join(" ", @​a)'
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is a, defsv is a at -e line 1.
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is a, defsv is a at -e line 1.
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is a, defsv is a at -e line 1.
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is 3, defsv is 3 at -e line 1.
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is 3, defsv is 3 at -e line 1.
stack 1 at -e line 1.
markstack 4 at -e line 1.
arg is 3, defsv is 3 at -e line 1.

The stack offset of 1 is now pointing to one of map’s arguments.

Found the bug. I’ll put the details in the commit message.

See <http​://perl5.git.perl.org/perl.git/commitdiff/0f602692a>.

--

Father Chrysostomos

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 2, 2015

From @khwilliamson

Thanks for submitting this ticket

The issue should be resolved with the release today of Perl v5.22, available at http​://www.perl.org/get.html
If you find that the problem persists, feel free to reopen this ticket

--
Karl Williamson for the Perl 5 porters team

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Jun 2, 2015

@khwilliamson - Status changed from 'pending release' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.