Bug #71937 [Com]: Php regular expression error with a large pattern

From: Date: Wed, 13 Apr 2016 10:45:40 +0000
Subject: Bug #71937 [Com]: Php regular expression error with a large pattern
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200522@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71937&edit=1

 ID:                 71937
 Comment by:         aayaresko at gmail dot com
 Reported by:        aayaresko at gmail dot com
 Summary:            Php regular expression error with a large pattern
 Status:             Feedback
 Type:               Bug
 Package:            *Regular Expressions
 Operating System:   Linux debian 3.16.0-4-amd64 #1 S
 PHP Version:        7.0.5
 Block user comment: N
 Private report:     N

 New Comment:

Not sure that correctly understood how to provide a backtrace.
I can't get result of debug_backtrace() or debug_print_backtrace() (if this is what provides a
backtrace) since php-cli session "sigfault" immediatly after execution one of the test
scripts.
Is there any other way that I can provide a backtrace?
Or maybe I'm doing something wrong?


Previous Comments:
------------------------------------------------------------------------
[2016-04-13 09:43:57] ab@php.net

Thanks for the report. Sadly i don't reproduce any crash on Jessie and Windows. Could you
please provide a backtrace?

Thanks.

------------------------------------------------------------------------
[2016-04-01 05:59:00] aayaresko at gmail dot com

Description:
------------
Performing any regular expression function with pattern similar to this one 
'/(:(?:nth-last-child|nth-of-type|nth-last-of-type|first-child|last-child|first-of-type|last-of-type|only-child|only-of-type|nth-child|first|last|gt|lt|eq|root|nth|empty|not|has|contains|parent|link|visited|hover|active)(?:\((?>[^()]|(?R))*\))?|\[(?>[^\[\]]|(?R))*\]|[#.][\w-]+)/'

causes a php error.
On linux operating systems this error can be reproduced with php-cli (command line interface) in
interactive mode.
Running php-fpm on this example leads to a similar result.

Test script:
---------------
preg_split('/(:(?:nth-last-child|nth-of-type|nth-last-of-type|first-child|last-child|first-of-type|last-of-type|only-child|only-of-type|nth-child|first|last|gt|lt|eq|root|nth|empty|not|has|contains|parent|link|visited|hover|active)(?:\((?>[^()]|(?R))*\))?|\[(?>[^\[\]]|(?R))*\]|[#.][\w-]+)/',
'#hello-world', 0, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);

preg_match('/(:(?:nth-last-child|nth-of-type|nth-last-of-type|first-child|last-child|first-of-type|last-of-type|only-child|only-of-type|nth-child|first|last|gt|lt|eq|root|nth|empty|not|has|contains|parent|link|visited|hover|active)(?:\((?>[^()]|(?R))*\))?|\[(?>[^\[\]]|(?R))*\]|[#.][\w-]+)/',
'#hello-world');

Actual result:
--------------
*** Error in `php': free(): invalid pointer: 0x00007ff5bb019564 ***

*** Error in `php': malloc(): smallbin double linked list corrupted: 0x0000000002c4dca0 ***



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



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


Thread (23 messages)

« previous php.bugs (#200522) next »