php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26219 Segmentation fault using regexp in php versions later than 4.3.3RC1
Submitted: 2003-11-12 09:46 UTC Modified: 2003-12-22 03:46 UTC
From: peter at normann dot com Assigned:
Status: Not a bug Package: Regexps related
PHP Version: 4.3.4 OS: Linux kernel 2.5.74
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: peter at normann dot com
New email:
PHP Version: OS:

 

 [2003-11-12 09:46 UTC] peter at normann dot com
Description:
------------
php crashes when using the preg_match function. Code included below. Works in php4.3.3RC1 but any later version causes segmentation fault.

The code is part of a text filter.

$output contains text with plain text and html mixed. The idea is anything between [html] and [/html] will go untouched by the filter.

I use dozens of other regular expressions, but preg_match is a sure killer. I can easily reproduce this behavior.



Reproduce code:
---------------
while (preg_match('/\[html]((.|\s)+?)\[\/html]/', $output, $htmlshow))
$output = str_replace($htmlshow[0], str_replace('<br />', '', strtr($htmlshow[1], array_flip(get_html_translation_table(HTML_ENTITIES)))), $output);

Actual result:
--------------
child pid xxxxx exit signal Segmentation fault (11)



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-12 11:00 UTC] iliaa@php.net
Please provide sample of source text on which the regex operates.
 [2003-11-12 11:24 UTC] peter at normann dot com
It's rather lengthy, but I have provided it at 
http://www.normann.com/bug/buggy.txt

Also, the whole function can be found at 
http://www.normann.com/bug/bug_code.txt

Thank you for taking your time...
 [2003-11-12 13:00 UTC] iliaa@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

I can verify the crash, however the crash is not the result of PHP code but rather due to a bug in the pcre library. Please report this bug to the maintainers of the pcre library.
 [2003-12-22 01:04 UTC] andrei@php.net
Could not reproduce with the latest PCRE library version 4.5.
 [2003-12-22 03:46 UTC] peter at normann dot com
Thank you Andrei.

I installed the latest pcre lib version 4.5 and linked the php-4.3.4 against it, but the problem persisted.

Then I downloaded the latest snapshot of 4.3.5-dev and compiled it using the bundled libpcre 4.5 and... problem solved :-)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 22:01:27 2024 UTC