#45735 [Bgs]: preg_match fails with Segmentation Fault on capturing subpattern
| From: | lbarnaud@php.net | Date: | Thu, 07 Aug 2008 11:27:30 +0000 |
| Subject: | #45735 [Bgs]: preg_match fails with Segmentation Fault on capturing subpattern | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-127722@lists.php.net to get a copy of this message | ||
ID: 45735
Updated by: lbarnaud@php.net
Reported By: johnston dot joshua at gmail dot com
Status: Bogus
Bug Type: PCRE related
Operating System: *
PHP Version: 5.2CVS, 5.3CVS, 6CVS (2008-08-06)
New Comment:
I seen that PCRE has a NO_RECURSE flag to avoid the recursion in
match() (described in pcre_exec.c).
Defining NO_RECURSE at compile time avoids this problem :)
diff -u -r1.38.2.3.2.10.2.3 config0.m4
--- ext/pcre/config0.m4 2 Jun 2008 14:12:20 -0000
1.38.2.3.2.10.2.3
+++ ext/pcre/config0.m4 7 Aug 2008 11:25:39 -0000
@@ -59,7 +59,7 @@
pcrelib/pcre_ord2utf8.c
pcrelib/pcre_refcount.c pcrelib/pcre_study.c \
pcrelib/pcre_tables.c
pcrelib/pcre_try_flipped.c pcrelib/pcre_valid_utf8.c \
pcrelib/pcre_version.c
pcrelib/pcre_xclass.c"
- PHP_NEW_EXTENSION(pcre, $pcrelib_sources php_pcre.c, no,,-
+ PHP_NEW_EXTENSION(pcre, $pcrelib_sources php_pcre.c, no,,-
PHP_ADD_BUILD_DIR($ext_builddir/pcrelib)
PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h pcrelib/])
AC_DEFINE(HAVE_BUNDLED_PCRE, 1, [ ])
Previous Comments:
------------------------------------------------------------------------
[2008-08-07 08:28:20] derick@php.net
AFAIK only be using a non-stack based evaluator (pcre_dfa_exec)...
which is not compatible with the perl regular expressions, see the
description at
http://manpages.courier-mta.org/htmlman3/pcre_dfa_exec.3.html
------------------------------------------------------------------------
[2008-08-06 17:47:50] johnston dot joshua at gmail dot com
I understand it is a known pcre behavior but does that mean it is ok to
let pcre trigger a segmentation fault? Is there no possible way to
handle this failure gracefully?
------------------------------------------------------------------------
[2008-08-06 17:40:50] felipe@php.net
.
------------------------------------------------------------------------
[2008-08-06 17:40:08] felipe@php.net
That is known PCRE behavior.
See: http://manpages.courier-mta.org/htmlman3/pcrestack.3.html
------------------------------------------------------------------------
[2008-08-06 17:29:06] johnston dot joshua at gmail dot com
In my case the parens were unnecessary so I removed them which stopped
the Seg Fault.
Is there a way to handle this error from inside php?
If I set pcre.backtrack_limit to any other value will it always seg
fault if it is too low?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/45735
--
Edit this bug report at http://bugs.php.net/?id=45735&edit=1