ID:               41050
 User updated by:  legolas558 at users dot sourceforge dot net
 Reported By:      legolas558 at users dot sourceforge dot net
 Status:           Bogus
 Bug Type:         PCRE related
 Operating System: Windows XP SP2
 PHP Version:      4.4.6
 New Comment:

I found a workaround for my own problem, maybe it will help other users
or help individuating the bug.

<?php
// by legolas558

$regex = "(?i:begin|start)\\s+([^']*('[^']*')*)*";

$old_php_regex = "/".$regex."/";

// notice the greedy/ungreedy change which actually works around the
segmentation fault
$bug41050_regex = "/".$regex."?/";

// test case
$subject = "begin\nnon string 'string' other non string";

// will work on any PHP - also the latest versions with PCRE7
preg_match_all($bug41050_regex, $subject, $m);

echo '<pre>';var_dump($m);echo '</pre>'; unset($m);

// will cause a segmentation fault (and so a 500 server error) if used
on PHP versions compiled with PCRE7
// preg_match_all($old_php_regex, $subject, $m);

echo '<pre>';var_dump($m);echo '</pre>';

?>


Previous Comments:
------------------------------------------------------------------------

[2007-04-11 14:08:23] legolas558 at users dot sourceforge dot net

Of course.

But did you check if the bug(s) also happens out of PHP? e.g. if it is
ONLY a PCRE bug?

------------------------------------------------------------------------

[2007-04-11 14:01:59] [EMAIL PROTECTED]

We can't fix PCRE.

------------------------------------------------------------------------

[2007-04-11 12:00:42] legolas558 at users dot sourceforge dot net

I have tested the subject and regex in a C snippet and the segmentation
fault does not happen

So the bug is someway related to PHP's usage (maybe initialization and
reset?) of the PCRE library

More tests would be needed, of course

------------------------------------------------------------------------

[2007-04-11 11:39:31] legolas558 at users dot sourceforge dot net

I understand.

I will try to contact the PCRE mantainer, and if he is not working on
the issue I will try to get my hands dirt and patch it myself. If I end
up with a patch for the PCRE library I hope it will be accepted in PHP's
 CVS tree

If the bug is not reproducible out of PHP (with a C testcase, for
example) there are high chances that it is a PHP-related bug.

I will now test the bug out of PHP and see if it still happens.

------------------------------------------------------------------------

[2007-04-11 11:34:30] [EMAIL PROTECTED]

http://sourceforge.net/tracker/index.php?func=detail&aid=1688293&group_id=10194&atid=360194
exists though.

------------------------------------------------------------------------

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/41050

-- 
Edit this bug report at http://bugs.php.net/?id=41050&edit=1

Reply via email to