Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 65264 - dev-lang/perl regular expression segfault
Summary: dev-lang/perl regular expression segfault
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Gentoo Perl team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-09-24 17:09 UTC by Daniel Westermann-Clark
Modified: 2006-07-26 18:41 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Test script illustrating the segfault (test.pl,374 bytes, text/plain)
2004-09-24 17:11 UTC, Daniel Westermann-Clark
Details
Line from my Apache access log which illustrates the problem (line.txt,32.06 KB, text/plain)
2004-09-24 17:12 UTC, Daniel Westermann-Clark
Details
gdb backtrace of segfault (gzipped) (bt.log.gz,29.35 KB, application/octet-stream)
2004-09-24 17:13 UTC, Daniel Westermann-Clark
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Westermann-Clark 2004-09-24 17:09:32 UTC
While working on a Perl program to parse Apache access logs, I came across Apache::LogRegex (http://search.cpan.org/~peterhi/Apache-LogRegex/lib/Apache/LogRegex.pm).  When I fed a simple script my access log, Perl crashed with a segmentation fault.

First I isolated the problem to the regular expression used by Apache::LogRegex (see test.pl, to be attached).  I also isolated the problem to one specific line of my access log (see line.txt, to be attached).  The resulting backtrace will also be attached.

The script works on a stock Perl 5.8.4 installation, so I commented out the Gentoo patches in /usr/portage/dev-lang/perl/perl-5.8.4-r1.ebuild.  The script worked until I enabled perl-5.8.4-picdl.patch.

I don't know what this patch does exactly, so I can't say if its necessary on my system.  Perl did seem to run without it, however.

Reproducible: Always
Steps to Reproduce:
1. perl test.pl < line.txt
Actual Results:  
Perl segfaults.

Expected Results:  
The following should be printed (part of the request is removed for the sake of
brevity):

$VAR1 = [ 
          'sabrina.webadmin.ufl.edu',
          '61.238.168.196',
          '-',
          '-',
          '[02/Aug/2004:13:42:44 -0400]',
          'SEARCH [...]',
          '414',
          '352',
          '-',
          '-'
        ];
1

Portage 2.0.50-r11 (default-x86-2004.2, gcc-3.3.4, glibc-2.3.3.20040420-r1, 2.6.8.1)
=================================================================
System uname: 2.6.8.1 i686 Intel(R) Xeon(TM) CPU 2.40GHz
Gentoo Base System version 1.4.16
distcc 2.16 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [enabled]
Autoconf: sys-devel/autoconf-2.59-r4
Automake: sys-devel/automake-1.8.5-r1
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CFLAGS="-mcpu=pentium4 -O2 -pipe -g3"
CHOST="i686-pc-linux-gnu"
COMPILER=""
CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config
/usr/kde/3.2/share/config /usr/kde/3.3/env /usr/kde/3.3/share/config
/usr/kde/3.3/shutdown /usr/kde/3/share/config /usr/lib/mozilla/defaults/pref
/usr/share/config /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-mcpu=pentium4 -O2 -pipe -g3"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs ccache distcc nostrip sandbox userpriv"
GENTOO_MIRRORS="http://open-systems.ufl.edu/mirrors/gentoo
http://gentoo.oregonstate.edu http://www.ibiblio.org/pub/Linux/distributions/gentoo"
MAKEOPTS="-j5"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://bugs.webadmin.ufl.edu/gentoo-portage"
USE="X aalib acpi alsa apm avi berkdb bitmap-fonts cdr crypt cups debug
divx4linux dvd encode foomaticdb gdbm gif gnome gpm gtk gtk2 gtkhtml imlib java
jpeg kde libg++ libwww mad maildir mikmod mmx motif mozilla mpeg ncurses nls
oggvorbis opengl oss pam pdflib perl png ppds python qt quicktime readline sdl
slang spell ssl svga tcpd tiff truetype x86 xml xml2 xmms xprint xv xvid zlib"
Comment 1 Daniel Westermann-Clark 2004-09-24 17:11:22 UTC
Created attachment 40333 [details]
Test script illustrating the segfault

This script takes lines from an Apache access log on STDIN, parses them using a
regular expression, and prints the results using Data::Dumper.
Comment 2 Daniel Westermann-Clark 2004-09-24 17:12:32 UTC
Created attachment 40334 [details]
Line from my Apache access log which illustrates the problem

Feed this to the test script, e.g. perl test.pl < line.txt.
Comment 3 Daniel Westermann-Clark 2004-09-24 17:13:35 UTC
Created attachment 40335 [details]
gdb backtrace of segfault (gzipped)
Comment 4 Daniel Westermann-Clark 2004-12-06 15:08:29 UTC
This still occurs on dev-lang/perl-5.8.5-r2 and the corresponding sys-devel/libperl-5.8.5 with a similar segmentation fault.
Comment 5 Michael Cummings (RETIRED) gentoo-dev 2005-07-19 16:40:54 UTC
Daniel,

I am afraid I am just now backtracking through the neglected pile of perl@g.o
bugs. Did you post this to perl-porters? I'm looking through why the patch was
ever applied, not even convinced it affected us (and yet at the same, not
convinced it didn't affect some archs at the same time). bah. i hate finding
old, interesting bugs.
Comment 6 Daniel Westermann-Clark 2005-07-21 18:33:03 UTC
Hi, Michael.  Thanks for getting back to me.

I'm not on p5p, so I did not raise the issue there.

I know very little about PIC, but I found a post from 2002 about something related:

http://groups-beta.google.com/group/perl.perl5.porters/browse_thread/thread/fb39cdf3020d0942?fwc=1

If I can help test anything, let me know.
Comment 7 Jakub Moc (RETIRED) gentoo-dev 2005-09-04 04:12:20 UTC
Mass re-assign.
Comment 8 Jakub Moc (RETIRED) gentoo-dev 2005-11-09 09:11:06 UTC
Mass re-assign.
Comment 9 Jakub Moc (RETIRED) gentoo-dev 2006-07-23 07:24:00 UTC
Closing this, feel free to reopen if it's still an issue w/ latest stable perl (5.8.8-r2 ATM).

*** This bug has been marked as a duplicate of 72109 ***
Comment 10 Daniel Westermann-Clark 2006-07-23 11:21:15 UTC
(In reply to comment #9)
> Closing this, feel free to reopen if it's still an issue w/ latest stable perl
> (5.8.8-r2 ATM).

The segfault still occurs on 5.8.8-r2.

The test script attached to bug 72109 works with or without the picdl patch, as does the simplified test case at http://www.livejournal.com/community/perl/61223.html (mentioned in bug 72109).

This bug is definitely a case of stack smashing, since increasing the limit causes the problem to go away:

[13:56:25 dwc@fortuna ~]$ ulimit -s 8192
[13:56:30 dwc@fortuna ~]$ perl test.pl < line.txt
Segmentation fault
[13:57:46 dwc@fortuna ~]$ ulimit -s 16384
[13:57:48 dwc@fortuna ~]$ perl test.pl < line.txt
(expected test output)

Disabling the picdl patch still "fixes" the issue regardless of stack size, though may create other problems I'm not seeing.

I think this is still a bug, though I'll understand if it's considered a WONTFIX.
Comment 11 Jakub Moc (RETIRED) gentoo-dev 2006-07-25 16:09:32 UTC
(In reply to comment #10)
> The segfault still occurs on 5.8.8-r2.
> 
> The test script attached to bug 72109 works with or without the picdl patch, as
> does the simplified test case at
> http://www.livejournal.com/community/perl/61223.html (mentioned in bug 72109).

Not here. Can't reproduce any segfault.
Comment 12 Daniel Westermann-Clark 2006-07-26 18:41:39 UTC
(In reply to comment #11)
> Not here. Can't reproduce any segfault.

Interesting.  mcummings was able to reproduce it in one location, so I'm not totally crazy.  ;)

yuval also pointed me to http://rt.perl.org/rt3/Public/Bug/Display.html?id=38717 - which mentions some similar issues.

I'm content to close this, as it seems to be a perl issue and not a packaging one.  The picdl patch seems to have been a false data point.