#23633 [NEW]: Seg. Fault on ugly preg matching

From: Date: Thu, 15 May 2003 04:22:09 +0000
Subject: #23633 [NEW]: Seg. Fault on ugly preg matching
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-39682@lists.php.net to get a copy of this message
From: sprice at wisc dot edu Operating system: Mac OS 10.2.6 PHP version: 4CVS-2003-05-14 (stable) PHP Bug Type: Reproducible crash Bug description: Seg. Fault on ugly preg matching This code: <?php $glossary = file_get_contents( '/Users/sprice/Desktop/ glossary.htm' ); $matches = array(); preg_match_all( '/<td width="140"><b><font face="Arial, Helvetica, sans-serif" size="2">(\S|\s)+<\/font><\/ b><\/td>\s+<td width="525">/', $glossary, $matches ); ?> (glossary.htm can be found here: http://botit.botany.wisc.edu/courses/structure_cd/ glossary.htm ) causes a segmentation fault (at least when run from the CLI). I suspect it is because it matches approx. 25764 (227^2/2) things in the given html document. This also occurs when you replace preg_match_all() with preg_match(). This is output from GDB (Someone might want to duplicate results because I don't know what I am doing w/ GDB): Program received signal EXC_BAD_ACCESS, Could not access memory. match (eptr=0x49907f "ze=\"2\">multiple \r\n", ' ' <repeats 18 times>, "nuclei bounded by a single cell wall</font></td>\r\n", ' ' <repeats 14 times>, "</ tr>\r\n", ' ' <repeats 14 times>, "<tr> \r\n", ' ' tr> <repeats 16 times>, "<td width=\"140\"><b><font face=\"Arial, Helvetica, sans-se"..., ecode=0x46f62f "=", offset_top=4, md=0xbfffd790, ims=0, eptrb=0xbff80290, flags=2) at /usr/local/php/php4- STABLE-200305150330/ext/pcre/pcrelib/pcre.c:4136 4136 { I can see why PHP would crash, but any crash is a bad crash, no? -- Edit bug report at http://bugs.php.net/?id=23633&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=23633&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=23633&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=23633&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=23633&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=23633&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=23633&r=support Expected behavior: http://bugs.php.net/fix.php?id=23633&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=23633&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=23633&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=23633&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23633&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=23633&r=dst IIS Stability: http://bugs.php.net/fix.php?id=23633&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=23633&r=gnused

« previous php.bugs (#39682) next »