Mailing List Archive

for (@ARGV) { while (<>) { $any{$_}++; } } coredumps
I believe a longer version of that one was reported here earlier (by Darrin
Mossor <darrinm@lmc.com>), but I was surprised to discover this very short
case. This one coredumps after reading in 5 lines from the first input file
on SunOS 4.1.3.

The body of the while can be anything that wishes to store away the
contents of $_.

I'll guess the underlying problem is that while loops do not localize $_,
so perl gets confused between the foreach's $_ and the while's. Why the
coredump only happens with 'while (<>) {...}' and not when an explicit
filehandle is used, is not clear. The ensuing memory corruption seems
to blow my gdb's bearings on the program stack, and I can't even get a
backtrace from it.

- Sarathy.
gsar@engin.umich.edu

Summary of my perl5 (patchlevel 1) configuration:
Platform:
osname=sunos, osver=4.1.3_u1, archname=sun4-sunos
uname='sunos aatma.eng 4.1.3_u1 2 sun4m '
hint=previous
Compiler:
cc='cc', optimize='-g', ld='ld'
cppflags='-DDEBUGGING'
ccflags ='-DDEBUGGING'
ldflags =''
stdchar='unsigned char', d_stdstdio=define, usevfork=true
voidflags=15, castflags=0, d_casti32=define, d_castneg=define
intsize=4, alignbytes=8, usemymalloc=y, randbits=31
Libraries:
so=so
libpth=/lib /usr/lib /usr/ucblib /usr/local/lib /l/local/lib
libs=-lnsl -ldbm -ldl -lm -lc -lposix
libc=/usr/lib/libc.so.1.9.3
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef
cccdlflags='-pic', ccdlflags=' ', lddlflags='-assert nodefinitions'