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

Crash Perl with binmode(STDERR, ':encoding(wildlybad)') #9288

Open
p5pRT opened this issue Apr 11, 2008 · 6 comments
Open

Crash Perl with binmode(STDERR, ':encoding(wildlybad)') #9288

p5pRT opened this issue Apr 11, 2008 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Apr 11, 2008

Migrated from rt.perl.org#52786 (status was 'open')

Searchable as RT52786$

@p5pRT
Copy link
Author

p5pRT commented Apr 11, 2008

From tco2@cornell.edu

This is a bug report for perl from tco2@​cornell.edu,
generated with the help of perlbug 1.36 running under perl 5.10.0.

This crashes Perl

perl -e "binmode(STDERR, '​:encoding(wildlybad)') or print 'fail ' ; print 'hi' "

Perl Ver| Platform | result
--------+-----------------------------------------+----------------------
5.10.0 | Solaris 9 Sparc, Manually built Sun CC | silently terminates
5.8.8 | Solaris 9 Sparc, Manually built Sun CC | Segmentation fault (core dumped)
5.8.6 | Mac OS X 10.4.11 Intel vendor provided | Segmentation fault
5.8.6 | Mac OS X 10.4.11 PPC vendor provided | Segmentation fault
5.8.1 | Mac OS X 10.3.9 PPC vendor provided | Segmentation fault

5.6.1 | Solaris 9 Sparc, Manually built gcc CC | warns then terminates
  Unknown discipline '​:encoding(wildlybad)' at -e line 1.
5.6.1 | Solaris 9 Sparc, Vendor provided | warns then terminates
  Unknown discipline '​:encoding(wildlybad)' at -e line 1.

In none of the above cases is either the 'fail ' or the 'hi' printed
As far as I can tell the binmode never returns
  Actually the crash occurs with just
  perl -e "binmode(STDERR, '​:encoding(wildlybad)')
  the print statements are just there to suggest that binmode does not return

Similar results occur when the command script is put in a file.

By contrast changing STDERR to STDOUT results in normal termination
for all of the above except the 5.6.1 lines
with binmode returning some flavor of false, and the script printing
  Cannot find encoding "wildlybad" at -e line 1.
  fail hi
(this is the behavior I expected)

The 5.6.1 lines appears to behave the same for STDOUT as it does for STDERR
... that is it warns and terminates abnormally

I discovered this when trying to figure out why use open '​:locale' '​:locale'
crashed on Solaris 9 with the default locale. The problem is that Solaris
reports the C (or POSIX) locale as '646' (short for ISO646) and Encode​::Alias
does not recognize '646' so it calls binmode with '​:encoding(646)'
which caused the above crash.
And I was looking at use open ... because Test-Simple just introduced a
test of utf8 that does a use open with a '​:locale' argument, and it was
crashing.

Here are excerpts of running some of the above under truss(1) on Solaris 9

======================================================================
Perl v5.10.0==================================================
...
stat64("/l/tool/perl/5.10.0/001.01/originalpkg/lib/sun4-solaris/Encode/Config.pm
", 0xFFBFE9D0) = 0
open64("/l/tool/perl/5.10.0/001.01/originalpkg/lib/sun4-solaris/Encode/Config.pm
", O_RDONLY) = 3
ioctl(3, TCGETA, 0xFFBFE744) Err#25 ENOTTY
llseek(3, 0, SEEK_CUR) = 0
brk(0x001F0320) = 0
brk(0x001F2320) = 0
read(3, " #\n # D e m a n d - l".., 4096) = 4096
brk(0x001F2320) = 0
brk(0x001F4320) = 0
getcontext(0xFFBFE670)
getcontext(0xFFBFE548)
getcontext(0xFFBFE670)
getcontext(0xFFBFE548)
brk(0x001F4320) = 0
brk(0x001F6320) = 0
brk(0x001F6320) = 0
brk(0x001F6320) = 0
brk(0x001F8320) = 0
read(3, " E n c o d e : : U n i c".., 4096) = 1922
getcontext(0xFFBFE7C0)
getcontext(0xFFBFE7C0)
getcontext(0xFFBFE7C0)
brk(0x001F8320) = 0
brk(0x001FA320) = 0
llseek(3, 5954, SEEK_SET) = 5954
llseek(3, 0, SEEK_CUR) = 5954
close(3) = 0
brk(0x001FA320) = 0
brk(0x001FC320) = 0
brk(0x001FC320) = 0
brk(0x001FE320) = 0
brk(0x001FE320) = 0
brk(0x00200320) = 0
stat64("/l/tool/perl/5.10.0/001.01/originalpkg/lib/sun4-solaris/Encode/ConfigLoc
al.pmc", 0xFFBFEAC8) Err#2 ENOENT
stat64("/l/tool/perl/5.10.0/001.01/originalpkg/lib/sun4-solaris/Encode/ConfigLoc
al.pm", 0xFFBFE9D0) Err#2 ENOENT
stat64("/l/tool/perl/5.10.0/001.01/originalpkg/lib/Encode/ConfigLocal.pmc", 0xFF
BFEAC8) Err#2 ENOENT
stat64("/l/tool/perl/5.10.0/001.01/originalpkg/lib/Encode/ConfigLocal.pm", 0xFFB
FE9D0) Err#2 ENOENT
stat64("/l/tool/perl/5.10.0/001.01/site000.001/lib/sun4-solaris/Encode/ConfigLoc
al.pmc", 0xFFBFEAC8) Err#2 ENOENT
stat64("/l/tool/perl/5.10.0/001.01/site000.001/lib/sun4-solaris/Encode/ConfigLoc
al.pm", 0xFFBFE9D0) Err#2 ENOENT
stat64("/l/tool/perl/5.10.0/001.01/site000.001/lib/Encode/ConfigLocal.pmc", 0xFF
BFEAC8) Err#2 ENOENT
stat64("/l/tool/perl/5.10.0/001.01/site000.001/lib/Encode/ConfigLocal.pm", 0xFFB
FE9D0) Err#2 ENOENT
stat64("./Encode/ConfigLocal.pmc", 0xFFBFEAC8) Err#2 ENOENT
stat64("./Encode/ConfigLocal.pm", 0xFFBFE9D0) Err#2 ENOENT
getcontext(0xFFBFE8C8)
setcontext(0xFFBFE8C8)
stat64("/l/tool/perl/5.10.0/001.01/originalpkg/lib/sun4-solaris/Encode/Encoding.
pmc", 0xFFBFEAC8) Err#2 ENOENT
stat64("/l/tool/perl/5.10.0/001.01/originalpkg/lib/sun4-solaris/Encode/Encoding.
pm", 0xFFBFE9D0) = 0
open64("/l/tool/perl/5.10.0/001.01/originalpkg/lib/sun4-solaris/Encode/Encoding.
pm", O_RDONLY) = 3
ioctl(3, TCGETA, 0xFFBFE744) Err#25 ENOTTY
llseek(3, 0, SEEK_CUR) = 0
read(3, " p a c k a g e E n c o".., 4096) = 4096
brk(0x00200320) = 0
brk(0x00202320) = 0
getcontext(0xFFBFE670)
getcontext(0xFFBFE548)
getcontext(0xFFBFE670)
getcontext(0xFFBFE548)
llseek(3, 1496, SEEK_SET) = 1496
llseek(3, 0, SEEK_CUR) = 1496
close(3) = 0
ioctl(2, TCGETA, 0xFFBFF54C) = 0
getcontext(0xFFBFF128)
getcontext(0xFFBFEE08)
setcontext(0xFFBFEE08)
getcontext(0xFFBFF6D8)
getcontext(0xFFBFF430)
getcontext(0xFFBFF430)
... 52 lines in all ...
getcontext(0xFFBFF430)
getcontext(0xFFBFF430)
getcontext(0xFFBFF430)
_exit(9)

======================================================================
Perl v5.8.8==================================================
...
stat64("/l/tool/perl/5.8.8/001.02/lib/sun4-solaris/Encode/Config.pm", 0xFFBFE8A0
) = 0
open64("/l/tool/perl/5.8.8/001.02/lib/sun4-solaris/Encode/Config.pm", O_RDONLY)
= 3
fstat64(3, 0xFFBFBF00) = 0
brk(0x001D9D70) = 0
brk(0x001DBD70) = 0
fstat64(3, 0xFFBFBDA8) = 0
ioctl(3, TCGETA, 0xFFBFBE8C) Err#25 ENOTTY
read(3, " #\n # D e m a n d - l".., 8192) = 6313
llseek(3, 0, SEEK_CUR) = 6313
brk(0x001DBD70) = 0
brk(0x001DDD70) = 0
getcontext(0xFFBFE628)
getcontext(0xFFBFE460)
llseek(3, 0, SEEK_CUR) = 6313
brk(0x001DDD70) = 0
brk(0x001DFD70) = 0
llseek(3, 0, SEEK_CUR) = 6313
llseek(3, 0, SEEK_CUR) = 6313
llseek(3, 0, SEEK_CUR) = 6313
llseek(3, 0, SEEK_CUR) = 6313
brk(0x001DFD70) = 0
brk(0x001E1D70) = 0
llseek(3, 0, SEEK_CUR) = 6313
llseek(3, 0, SEEK_CUR) = 6313
llseek(3, 0, SEEK_CUR) = 6313
llseek(3, 0, SEEK_CUR) = 6313
llseek(3, 0, SEEK_CUR) = 6313
llseek(3, 0, SEEK_CUR) = 6313
llseek(3, 0xFFFFFFFFFFFFFFC0, SEEK_CUR) = 6249
close(3) = 0
brk(0x001E1D70) = 0
stat64("/l/tool/perl/5.8.8/001.02/site002.001/lib/sun4-solaris/Encode/ConfigLoca
l.pmc", 0xFFBFEA30) Err#2 ENOENT
stat64("/l/tool/perl/5.8.8/001.02/site002.001/lib/sun4-solaris/Encode/ConfigLoca
l.pm", 0xFFBFE8A0) Err#2 ENOENT
stat64("/l/tool/perl/5.8.8/001.02/site002.001/lib/Encode/ConfigLocal.pmc", 0xFFB
FEA30) Err#2 ENOENT
stat64("/l/tool/perl/5.8.8/001.02/site002.001/lib/Encode/ConfigLocal.pm", 0xFFBF
E8A0) Err#2 ENOENT
stat64("/l/tool/perl/5.8.8/001.02/site_h2ph/sun4u-solaris9-hermes2-20071216/Enco
de/ConfigLocal.pmc", 0xFFBFEA30) Err#2 ENOENT
stat64("/l/tool/perl/5.8.8/001.02/site_h2ph/sun4u-solaris9-hermes2-20071216/Enco
de/ConfigLocal.pm", 0xFFBFE8A0) Err#2 ENOENT
stat64("/l/tool/perl/5.8.8/001.02/lib/sun4-solaris/Encode/ConfigLocal.pmc", 0xFF
BFEA30) Err#2 ENOENT
stat64("/l/tool/perl/5.8.8/001.02/lib/sun4-solaris/Encode/ConfigLocal.pm", 0xFFB
FE8A0) Err#2 ENOENT
stat64("/l/tool/perl/5.8.8/001.02/lib/Encode/ConfigLocal.pmc", 0xFFBFEA30) Err#2
ENOENT
stat64("/l/tool/perl/5.8.8/001.02/lib/Encode/ConfigLocal.pm", 0xFFBFE8A0) Err#2
ENOENT
stat64("/l/tool/perl/5.8.8/001.02/site01/lib/sun4-solaris/Encode/ConfigLocal.pmc
", 0xFFBFEA30) Err#2 ENOENT
stat64("/l/tool/perl/5.8.8/001.02/site01/lib/sun4-solaris/Encode/ConfigLocal.pm"
, 0xFFBFE8A0) Err#2 ENOENT
stat64("/l/tool/perl/5.8.8/001.02/site01/lib/Encode/ConfigLocal.pmc", 0xFFBFEA30
) Err#2 ENOENT
stat64("/l/tool/perl/5.8.8/001.02/site01/lib/Encode/ConfigLocal.pm", 0xFFBFE8A0)
Err#2 ENOENT
stat64("./Encode/ConfigLocal.pmc", 0xFFBFEA30) Err#2 ENOENT
stat64("./Encode/ConfigLocal.pm", 0xFFBFE8A0) Err#2 ENOENT
getcontext(0xFFBFE830)
setcontext(0xFFBFE830)
ioctl(2, TCGETA, 0xFFBFF534) = 0
llseek(2, 0, SEEK_CUR) = 145984
getcontext(0xFFBFF0C0)
brk(0x001E3D70) = 0
brk(0x001E5D70) = 0
brk(0x001E5D70) = 0
brk(0x001E7D70) = 0
brk(0x001E7D70) = 0
... a total of 3800 lines ending in
brk(0x011C3D70) = 0
brk(0x011C5D70) = 0
  Incurred fault #6, FLTBOUNDS %pc = 0x000A687C
  siginfo​: SIGSEGV SEGV_MAPERR addr=0xFF3FFF80
  Received signal #11, SIGSEGV [default]
  siginfo​: SIGSEGV SEGV_MAPERR addr=0xFF3FFF80


Flags​:
  category=core
  severity=critical


Site configuration information for perl 5.10.0​:

Configured by msunp01 at Fri Apr 4 15​:54​:20 EDT 2008.

Summary of my perl5 (revision 5 version 10 subversion 0) configuration​:
  Platform​:
  osname=solaris, osvers=2.9, archname=sun4-solaris
  uname='sunos hermes2 5.9 generic_118558-34 sun4u sparc sunw,ultraax-i2 '
  config_args='-Dprefix=/l/tool/perl/5.10.0/001.01/originalpkg -Dsiteprefix=/l/tool/perl/5.10.0/001.01/site000.001 -Dusesitecustomize -Dman1ext=1pm -Dman3ext=3pm'
  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='/opt/SUNWspro/bin/cc', ccflags =' -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
  optimize='-O',
  cppflags=''
  ccversion='Sun WorkShop 6 2000/06/19 C 5.1 Patch 109491-02', gccversion='', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='/opt/SUNWspro/bin/cc', ldflags =' -L/usr/lib -L/usr/ccs/lib -L/opt/SUNWspro/WS6/lib '
  libpth=/usr/lib /usr/ccs/lib /opt/SUNWspro/WS6/lib
  libs=-lsocket -lnsl -ldl -lm -lc
  perllibs=-lsocket -lnsl -ldl -lm -lc
  libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
  cccdlflags='-KPIC', lddlflags='-G -L/usr/lib -L/usr/ccs/lib -L/opt/SUNWspro/WS6/lib'

Locally applied patches​:
 


@​INC for perl 5.10.0​:
  /l/tool/perl/5.10.0/001.01/originalpkg/lib/sun4-solaris
  /l/tool/perl/5.10.0/001.01/originalpkg/lib
  /l/tool/perl/5.10.0/001.01/site000.001/lib/sun4-solaris
  /l/tool/perl/5.10.0/001.01/site000.001/lib
  .


Environment for perl 5.10.0​:
  HOME=/users/tco2
  LANG (unset)
  LANGUAGE (unset)
  LD_LIBRARY_PATH=/l/S/t12/app/oracle/product/9.2.0.1.0/lib32
  LOGDIR (unset)
  PATH=/usr/sbin​:/l/tool/perl/5.10.0/001.01/originalpkg/bin​:/l/tool/perl/5.10.0/001.01/originalpkg/script​:/usr/bin​:/usr/sfw/bin​:/usr/openwin/bin​:/usr/dt/bin​:/opt/common/bin​:/usr/ccs/bin​:/usr/ucb​:/l/kit/tw/bin​:/l/kit/01/bin​:/l/kit/httpd/bin​:/users/tco2/bin
  PERL_BADLANG (unset)
  SHELL=/opt/common/bin/tcsh

=============
Here is Perl -V for my 5.8.8 solaris version

Summary of my perl5 (revision 5 version 8 subversion 8) configuration​:
  Platform​:
  osname=solaris, osvers=2.9, archname=sun4-solaris
  uname='sunos hermes2 5.9 generic_118558-34 sun4u sparc sunw,ultraax-i2 '
  config_args='-Dusesitecustomize -Dprefix=/l/tool/perl/5.8.8/001.02'
  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='/opt/SUNWspro/bin/cc', ccflags =' -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
  optimize='-O',
  cppflags=''
  ccversion='Sun WorkShop 6 2000/06/19 C 5.1 Patch 109491-02', gccversion='', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='/opt/SUNWspro/bin/cc', ldflags =' -L/usr/lib -L/usr/ccs/lib -L/opt/SUNWspro/WS6/lib '
  libpth=/usr/lib /usr/ccs/lib /opt/SUNWspro/WS6/lib
  libs=-lsocket -lnsl -ldl -lm -lc
  perllibs=-lsocket -lnsl -ldl -lm -lc
  libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
  cccdlflags='-KPIC', lddlflags='-G -L/usr/lib -L/usr/ccs/lib -L/opt/SUNWspro/WS6/lib'

Characteristics of this binary (from libperl)​:
  Compile-time options​: PERL_MALLOC_WRAP USE_LARGE_FILES USE_PERLIO
  USE_SITECUSTOMIZE
  Built under solaris
  Compiled at Dec 9 2007 17​:50​:03
  @​INC​:
  /l/tool/perl/5.8.8/001.02/site002.001/lib/sun4-solaris
  /l/tool/perl/5.8.8/001.02/site002.001/lib
  /l/tool/perl/5.8.8/001.02/site_h2ph/sun4u-solaris9-hermes2-20071216
  /l/tool/perl/5.8.8/001.02/lib/sun4-solaris
  /l/tool/perl/5.8.8/001.02/lib
  /l/tool/perl/5.8.8/001.02/site01/lib/sun4-solaris
  /l/tool/perl/5.8.8/001.02/site01/lib
  .

==============


Flags​:
  category=core
  severity=critical


Site configuration information for perl 5.10.0​:

Configured by msunp01 at Fri Apr 4 15​:54​:20 EDT 2008.

Summary of my perl5 (revision 5 version 10 subversion 0) configuration​:
  Platform​:
  osname=solaris, osvers=2.9, archname=sun4-solaris
  uname='sunos hermes2 5.9 generic_118558-34 sun4u sparc sunw,ultraax-i2 '
  config_args='-Dprefix=/l/tool/perl/5.10.0/001.01/originalpkg -Dsiteprefix=/l/tool/perl/5.10.0/001.01/site000.001 -Dusesitecustomize -Dman1ext=1pm -Dman3ext=3pm'
  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='/opt/SUNWspro/bin/cc', ccflags =' -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
  optimize='-O',
  cppflags=''
  ccversion='Sun WorkShop 6 2000/06/19 C 5.1 Patch 109491-02', gccversion='', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='/opt/SUNWspro/bin/cc', ldflags =' -L/usr/lib -L/usr/ccs/lib -L/opt/SUNWspro/WS6/lib '
  libpth=/usr/lib /usr/ccs/lib /opt/SUNWspro/WS6/lib
  libs=-lsocket -lnsl -ldl -lm -lc
  perllibs=-lsocket -lnsl -ldl -lm -lc
  libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
  cccdlflags='-KPIC', lddlflags='-G -L/usr/lib -L/usr/ccs/lib -L/opt/SUNWspro/WS6/lib'

Locally applied patches​:
 


@​INC for perl 5.10.0​:
  /l/tool/perl/5.10.0/001.01/originalpkg/lib/sun4-solaris
  /l/tool/perl/5.10.0/001.01/originalpkg/lib
  /l/tool/perl/5.10.0/001.01/site000.001/lib/sun4-solaris
  /l/tool/perl/5.10.0/001.01/site000.001/lib
  .


Environment for perl 5.10.0​:
  HOME=/users/tco2
  LANG (unset)
  LANGUAGE (unset)
  LD_LIBRARY_PATH=/l/S/t12/app/oracle/product/9.2.0.1.0/lib32
  LOGDIR (unset)
  PATH=/usr/sbin​:/l/tool/perl/5.10.0/001.01/originalpkg/bin​:/l/tool/perl/5.10.0/001.01/originalpkg/script​:/usr/bin​:/usr/sfw/bin​:/usr/openwin/bin​:/usr/dt/bin​:/opt/common/bin​:/usr/ccs/bin​:/usr/ucb​:/l/kit/tw/bin​:/l/kit/01/bin​:/l/kit/httpd/bin​:/users/tco2/bin
  PERL_BADLANG (unset)
  SHELL=/opt/common/bin/tcsh

@p5pRT
Copy link
Author

p5pRT commented Apr 12, 2008

From nospam-abuse@bloodgate.com

On Friday 11 April 2008 23​:09​:06 Todd Olson wrote​:

perl -e "binmode(STDERR, '​:encoding(wildlybad)')

  # perl -e "binmode(STDERR, '​:encoding(wildlybad)')"
  Segmentation fault (core dumped)
  # perl -v

  This is perl, v5.8.8 built for x86_64-linux-gnu-thread-multi

All the best,

Tels

--
Signed on Sat Apr 12 13​:22​:34 2008 with key 0x93B84C15.
View my photo gallery​: http​://bloodgate.com/photos
PGP key on http​://bloodgate.com/tels.asc or per email.

"Memory is like an orgasm. It's a lot better if you don't have to fake
it."

  -- Seymore Cray, on virtual memory

@p5pRT
Copy link
Author

p5pRT commented Apr 12, 2008

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

@p5pRT
Copy link
Author

p5pRT commented Apr 14, 2008

From tco2@cornell.edu

Greetings,

Darn!

The subject should have been

Crash Perl with binmode(STDERR, '​:encoding(wildlybad)')
  ^^^

Regards,
Todd Olson

@p5pRT
Copy link
Author

p5pRT commented Apr 14, 2008

From tco2@cornell.edu

This is a bug report for perl from tco2@​cornell.edu,
generated with the help of perlbug 1.36 running under perl 5.10.0.

This crashes Perl

perl -e "binmode(STDERR, '​:encoding(wildlybad)') or print 'fail ' ; print 'hi' "

Perl Ver| Platform | result
--------+-----------------------------------------+--------------------
--
5.10.0 | Solaris 9 Sparc, Manually built Sun CC | silently terminates
5.8.8 | Solaris 9 Sparc, Manually built Sun CC | Segmentation fault (core dumped)
5.8.6 | Mac OS X 10.4.11 Intel vendor provided | Segmentation fault
5.8.6 | Mac OS X 10.4.11 PPC vendor provided | Segmentation fault
5.8.1 | Mac OS X 10.3.9 PPC vendor provided | Segmentation fault

5.6.1 | Solaris 9 Sparc, Manually built gcc CC | warns then terminates
  Unknown discipline '​:encoding(wildlybad)' at -e line 1.
5.6.1 | Solaris 9 Sparc, Vendor provided | warns then terminates
  Unknown discipline '​:encoding(wildlybad)' at -e line 1.

In none of the above cases is either the 'fail ' or the 'hi' printed
As far as I can tell the binmode never returns
  Actually the crash occurs with just
  perl -e "binmode(STDERR, '​:encoding(wildlybad)')
  the print statements are just there to suggest that binmode does not return

Similar results occur when the command script is put in a file.

By contrast changing STDERR to STDOUT results in normal termination
for all of the above except the 5.6.1 lines
with binmode returning some flavor of false, and the script printing
  Cannot find encoding "wildlybad" at -e line 1.
  fail hi
(this is the behavior I expected)

The 5.6.1 lines appears to behave the same for STDOUT as it does for STDERR
... that is it warns and terminates abnormally

I discovered this when trying to figure out why use open '​:locale' '​:locale'
crashed on Solaris 9 with the default locale. The problem is that Solaris
reports the C (or POSIX) locale as '646' (short for ISO646) and Encode​::Alias
does not recognize '646' so it calls binmode with '​:encoding(646)'
which caused the above crash.
And I was looking at use open ... because Test-Simple just introduced a
test of utf8 that does a use open with a '​:locale' argument, and it was
crashing.

Excerpts of running some of the above under truss(1) on Solaris 9 are in the original message
as are the information about perl

@p5pRT
Copy link
Author

p5pRT commented Jul 26, 2014

From @chorny

On Mon Apr 14 11​:02​:25 2008, toddolson wrote​:

   perl \-e "binmode\(STDERR\, '​:encoding\(wildlybad\)'\)
the print statements are just there to suggest that binmode does

not return

with perl 5.20.0

perl -e "binmode(STDIN, '​:encoding()')"
Cannot find encoding "" at -e line 1.

perl -e "binmode(STDERR, '​:encoding()')"

perl a.pl
Error​: Can't call method "encode" on an undefined value at a.pl line 2.

a.pl​:
eval {
binmode(STDERR, '​:encoding()');
};
print "Error​: $@​";

So, binmode(STDERR, '​:encoding()') does not raise a error in time and STDERR starts behaving incorrectly.

--
Alexandr Ciornii, http​://chorny.net

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

2 participants