Description of problem: a2ps hangs indefinitely while processing a large perl regular expression, consuming all available CPU. Version-Release number of selected component (if applicable): a2ps-4.13b-57.1 How reproducible: Every time Steps to Reproduce: 1. Create file.pl with the following contents: #!/usr/bin/perl -w while(<IN>){ # remove naughty characters s/[^\w\.\s\|\,\'\<\>\?\;\:\[\]\-\_\=\+\`\~\!\@\#\$\%\^\&\*\(\)\/\?\{\}q]//g; } close IN; 2. Run: a2ps -o- file.pl 3. No results, command hangs, 99% cpu consumed Actual results: Expected results: Additional info: Possibly a problem with perl.ssh? See http://osdir.com/ml/printing.a2ps.bugs/2006-11/msg00000.html
While looking at this again, I noticed that the command will eventually complete. On a 2.2Ghz Pentium 4 CPU the above command took about 22.5 hours of nearly dedicated CPU time to complete. The resulting PostScript for the regex is: (s) K (/[^\\w\\.\\s\\|\\,\\'\\<\\>\\?\\;\\:\\[\\]\\-\\_\\=\\+\\`\\~\\!\\@\\#\\$\\%\\^\\&\\*\\\(\\\)\\/\\?\\{\\}q]//g;) p n
I seem to have narrowed down that it is perl.ssh causing a2ps to take a long time to complete. The following modification to perl.ssh changes the completion time from 22.5 hours to under 1 second. However I don't know if this is a _wise_ change to make. =================================================================== RCS file: perl.ssh,v retrieving revision 1.1 diff -C4 -r1.1 perl.ssh *** perl.ssh 2007/09/25 14:38:25 1.1 --- perl.ssh 2007/09/25 18:15:09 *************** *** 105,115 **** # two regexps with a single char as delimiter (/(s|tr)/ # 1. The command: `tr' or `s' /(([[:punct:]])/ # 2. The delimiter /(/ # 3. The *two* regexps ! /(.|\\\\.)*/ # First regexp /\\3/ # Separator ! /(.|\\\\.)*/ # Second Regexp /)/ # /\\3)/ # Closer \1 Keyword_strong, \2 Plain), --- 105,115 ---- # two regexps with a single char as delimiter (/(s|tr)/ # 1. The command: `tr' or `s' /(([[:punct:]])/ # 2. The delimiter /(/ # 3. The *two* regexps ! /(\\\\.)*/ # First regexp /\\3/ # Separator ! /(\\\\.)*/ # Second Regexp /)/ # /\\3)/ # Closer \1 Keyword_strong, \2 Plain),
Thanks for the patch. I'm not sure either, but I don't think the consequences can be much worse that the symptom so I'll try it out for Fedora 8 (a2ps-4.13b-69.fc8). I'm not entirely convinced the patch is correct (in fact, it looks wrong in that there are other places left with the original regexp regexp) so I'll hold off from applying it in Red Hat Enterprise Linux for the time being.