sherman@unx.sas.com (Chris Sherman) (06/22/91)
A few months ago, somebody posted a little gem called mg, which was a
really fancy grep command which could do all kinds of neat things.
Well, it causes perl to dump core repeatedly now. I wish I had a non-stripped
'-g' perl sitting around so I could give you a stack trace, but it shouldn't
be too hard to reproduce the effect. I had some README's sitting in a
directory, so I did a:
% mg " or " RE*
Segmentation fault (core dumped)
If perl doesn't core dump, then the program just doesn't work, or it doesn't
work correctly. I can't find a situation where it does work anymore. I think
it is a reg exp problem since some of the fantatic looking errors look like:
% mg the RE*
README.SECOND:ThaThaThaThaThaThaThaThaThaThaThaThaThaThaThaThaThaThaThaTha
ThaThaThaThaThaThaThaThaThaThaThaThaThaThaThaThank you for your interest in
NOTE: The first line was cut off by me to keep lines < 80 columns for
purposes of mailing. Also, the string 'the' doesn't appear anywhere
in the line. This was a typical problem; it got the file right
(usually), but not the correct line.
Note: if you didn't save this one, send mail, and I can sent it too you.
The code is hideous looking, thus hard to trace, but it did work once.
Problem occurs on Sun4 and HPUX (all kinds). Perl v4p10.
Thanx,
--
Chris Sherman .................... sherman@unx.sas.com |
,-----------------------------------------'
/ Q: How many IBM CPU's does it take to execute a job?
| A: Four; three to hold it down, and one to rip its head off.
tchrist@convex.COM (Tom Christiansen) (06/22/91)
FYI, mg was posted:
29May91 Kazumasa Utashiro 18424 mg: multi-line grep<<When we are editing
and has Message-ID: <UTASHIRO.91May29164841@ext12.sra.co.jp>.
Anyway, while I don't get coredumps running the program at 4.009 or 4.010,
neither does it give me the right answer. Looking at the code, it is
keying off of whether $] > 4.003 and running different code depending.
The code it runs at newer patchlevels is this:
eval "while(/$opt_p/og$ig){push(\@x,length(\$`),length(\$&));}";
where $opt_p is your pattern. (The /o seems unneeded for a constant
pattern though, which you'll have after the qq interpolation.)
Playing with the debugger, I find that it doesn't like me to examine
$' in here -- it gives me a SEGV core dump if I do it. Here's a
trivial little test that also causes the problem to manifest:
$_ = "xxxxxxxxxx";
while (/x/g) {
print $`, '|', $&, '|', $', ++$i, "\n";
}
Larry?
--tom
--
Tom Christiansen tchrist@convex.com convex!tchrist
"So much mail, so little time."
flee@cs.psu.edu (Felix Lee) (06/23/91)
Perhaps it's the m//g bug.
regcomp.c:
357c357
< New(1002, r->startp, regnpar, char*);
---
> Newz(1002, r->startp, regnpar, char*);
tchrist@convex.COM (Tom Christiansen) (06/23/91)
From the keyboard of flee@cs.psu.edu (Felix Lee): :Perhaps it's the m//g bug. : :regcomp.c: :357c357 :< New(1002, r->startp, regnpar, char*); :--- :> Newz(1002, r->startp, regnpar, char*); Nope, sorry: still got coredumps. --tom -- Tom Christiansen tchrist@convex.com convex!tchrist "So much mail, so little time."
flee@cs.psu.edu (Felix Lee) (06/23/91)
Hmm. Right. Any m//g expression will not set $` or $' correctly. -- Felix
utashiro@sra.co.jp (Kazumasa Utashiro) (06/25/91)
In article <sherman.677589816@foster> sherman@unx.sas.com (Chris Sherman) writes: >A few months ago, somebody posted a little gem called mg, which was a >really fancy grep command which could do all kinds of neat things. Thank you. I thought it is not so valuable because I had only a few responses. I couldn't use 4.009 or 4.010 by now because I just came back to Tokyo from USENIX and INET'91 trip. (I still don't know how tchrist look like because I didn't take Perl tutorial...) >Well, it causes perl to dump core repeatedly now. I wish I had a non-stripped >'-g' perl sitting around so I could give you a stack trace, but it shouldn't >be too hard to reproduce the effect. I had some README's sitting in a >directory, so I did a: > % mg " or " RE* > Segmentation fault (core dumped) > >If perl doesn't core dump, then the program just doesn't work, or it doesn't >work correctly. I can't find a situation where it does work anymore. I think >it is a reg exp problem since some of the fantatic looking errors look like: As Tom Christiansen sais, it is because mg uses m//g syntax for higher versions than 4.003. I built 4.009 and 4.010 today and had same result as yours. I was thinking about adding cheking mechanism without $] comparison, but it seems very difficult to avoid core dump. So I think the easiest way to make it to work is removing period in condition like this. 114c114 < if ($] > 4.003) { --- > if ($] > 4003) { I'll post updated version when m//g became available. --- K. Utashiro utashiro@sra.co.jp