Bug in 4.1bsd csh
gorlick at trwrb.UUCP
gorlick at trwrb.UUCP
Wed May 9 09:24:31 AEST 1984
1984-0017 TRW/UNIX Modification 1984-0017
NAME
csh - core dumps when evaluating =~ operator
DATE ENACTED
May 8, 1984
KEYWORDS
=~, csh(1)
PROBLEM DESCRIPTION
The csh(1) occasionally dumps core when evaluating the pat-
tern matching operator `=~'.
BACKGROUND
For example, the script
#! /bin/csh
foreach pattern ('*' '?' '[a-z]' 'f*' 'fo?bar' '*oba?')
@ x = (foobar =~ "${pattern}")
echo $x
end
produces the output
0
0
0
0
0
assertion botched: p->ptr > allocp && p->ptr <= alloct
Illegal instruction (core dumped)
RESOLUTION
The problem is that the csh is trying to cfree(3) pattern
storage never allocated by calloc(3) in the first place. In
the routine exp6() in sh.exp.c change the last line
return (ignore&NOGLOB ? cp : globone(cp));
to
return (ignore&NOGLOB ? savestr(cp) : globone(cp));
FILES
/usr/src/cmd/csh/sh.exp.c
REQUESTOR
Michael Gorlick
AUTHOR
Michael Gorlick
4.1bsd TRW (5/8/84) 1
1984-0017 TRW/UNIX Modification 1984-0017
SEE ALSO
Thanks to Mike Urban who brought the bug and its fix to my
attention.
4.1bsd TRW (5/8/84) 2
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list