[comp.lang.perl] Problem with fileop

Andrew.Vignaux@comp.vuw.ac.nz (Andrew Vignaux) (05/29/90)

I've found a problem with some of the fileops and an empty set of
arguments.  I realise that this is generally discouraged, but I found
it while I was playing around with some "command-line"rs, and it, er,
shouldn't dump core.

Machines: HP 9000/300 running MORE/bsd, HP 9000/800 HPUX 7.0, Sun 3 -- 4.0.3

Example:
	$ perl -v
	$Header: perly.c,v 3.0.1.5 90/03/27 16:20:57 lwall Locked $
	Patch level: 18

	$ perl -e 'close();'
	Segmentation fault (core dumped)
do_close (stab=(STAB *) 0x0, explicit=1 '\001') (doio.c line 369)
369         if (stio->ifp) {

or:
	$ perl -e '<>; getc();'
	hello
	x
	Segmentation fault (core dumped)
0x17978 in eval (arg=(ARG *) 0x4ca88, gimme=0, sp=-1) (eval.c line 930)
930     *str->str_ptr = getc(stab_io(stab)->ifp); /* should never be EOF */

There are probably others :-(

perl -D1024 for the "close" looks like
{
    C_TYPE = EXPR
    C_ADDR = 0x4af88
    C_NEXT = 0x0
    C_LINE = 1 (0x4af88)
    C_OPT = CFT_EVAL
    C_FLAGS = (COND,TERM)
    C_EXPR = {
        OP_TYPE = CLOSE
        OP_LEN = 1
        [1]ARG_TYPE = WORD
        [1]ARG_STAB = {}
    }
    AC_STAB = NULL
    AC_EXPR = NULL
}

I'm afraid I got lost in the maze of twisty little yacc clauses -- all
alike.  Well, not really, but there are a lot of them :-)

print "Just a (rare) core dump,\n"; lstat();

Andrew
-- 
Domain address: Andrew.Vignaux@comp.vuw.ac.nz