php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33640 preg_match will cause a segmentation fault on pattern
Submitted: 2005-07-11 08:53 UTC Modified: 2005-07-11 09:29 UTC
From: david dot tulloh at infaze dot com dot au Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5CVS-2005-07-11 (dev) OS: debian linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
33 - 16 = ?
Subscribe to this entry?

 
 [2005-07-11 08:53 UTC] david dot tulloh at infaze dot com dot au
Description:
------------
While trying to craft a relatively complex regex string I caused php to consistently segfault.  I then tracked it down to a smaller simpler pattern.


PHP 5.1.0-dev (cli) (built: Jul  6 2005 10:55:39)
Copyright (c) 1997-2005 The PHP Group
Zend Engine v2.1.0-dev, Copyright (c) 1998-2004 Zend Technologies


Reproduce code:
---------------
<?php
preg_match('/(?(?=a) (?R) )/x', 'a', $arr);
preg_match_all('/(?(?=a) (?R) )/x', 'a', $arr);
echo 'fin', "\n";  # will never print
?>

Either preg line will cause the fault.

Expected result:
----------------
Anything but a segmentation fault, some kind of error would be nice.

Actual result:
--------------
Segmentation fault

gdb:
Starting program: /usr/bin/php -f pcrash.php
[Thread debugging using libthread_db enabled]
[New Thread -1211468032 (LWP 22573)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1211468032 (LWP 22573)]
0xb7f58362 in pcre_compile () from /usr/lib/libpcre.so.3


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-11 08:58 UTC] david dot tulloh at infaze dot com dot au
It looks like the segfault actually originates from within libpcre.  I'm going to try a newer version.

Is there anyway for php to catch the library as it falls over?
 [2005-07-11 09:29 UTC] sniper@php.net
You're hitting the PCRE limitations: http://www.pcre.org/pcre.txt

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 23:01:28 2024 UTC