Bug #68628 [NEW]: preg_match() causes stack overflow exception

From: Date: Fri, 19 Dec 2014 09:22:37 +0000
Subject: Bug #68628 [NEW]: preg_match() causes stack overflow exception
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-189126@lists.php.net to get a copy of this message
From:             roman dot paska at gmail dot com
Operating system: Windows 7
PHP version:      5.4.36
Package:          *Regular Expressions
Bug Type:         Bug
Bug description:preg_match() causes stack overflow exception

Description:
------------
preg_match() crashes PHP & Apache with stack overflow exception on
Windows 7.

I'm not able to reproduce it with plain PHP code. It crashes using
Drupal 7 under some circumstances.

Regular expression is
preg_match("/^(?:[\w#!:\.\?\+=&@$'~*,;\/\(\)\[\]\-]|%[0-9a-f]{2})+$/i",
$url) 

More details to follow.

Actual result:
--------------
In
httpd__PID__6364__Date__12_19_2014__Time_10_40_54AM__870__Second_Chance_Exception_C00000FD.dmp
the assembly instruction at php5ts!php_pcre_compile+99c8 in C:\Program
Files\PHP54\php5ts.dll from The PHP Group has caused a stack overflow
exception (0xC00000FD) when trying to write to memory location
0x00000001 on thread 9

Type of Analysis Performed - Combined Crash/Hang Analysis
Operating System - Windows 7Service Pack 1
Number Of Processors - 4
Process ID - 6364
Process Image - c:\Program Files\Apache Software
Foundation\Apache24\bin\httpd.exe
System Up-Time - 1 day(s) 00:06:33
Process Up-Time - 00:00:04
Processor Type - X86
Process Bitness - 32-Bit

Thread 9 - System ID 2100
Entry point	  libhttpd!ap_regkey_value_remove+11a0
Create time	  19.12.2014 10:40:50
Time spent in user mode	  0 Days 00:00:00.390
Time spent in kernel mode	  0 Days 00:00:00.156



This thread is not fully resolved and may or may not be a problem.
Further analysis of these threads may be required.

Function
php5ts!php_pcre_compile+99c8
0x00989680
php5ts!php_pcre_match_impl+269
php5ts!pcre_get_compiled_regex_cache+4a9
php5ts!php_pcre_grep_impl+394
php5ts!php_pcre_grep_impl+3b6
php5ts!zval_copy_ctor_func+4a8
php5ts!zval_add_ref+1385
php5ts!execute+1fe
php5ts!zend_call_function+379
php5ts!zval_add_ref+2c22
php5ts!php_error_log_ex+323
php5ts!zval_copy_ctor_func+4a8
php5ts!add_assoc_stringl_ex+1b9
php5ts!zval_add_ref+1385
php5ts!execute+1fe
php5ts!zend_call_function+379
php5ts!zval_add_ref+2c22
php5ts!php_error_log_ex+323
php5ts!zval_copy_ctor_func+4a8
php5ts!add_assoc_stringl_ex+286
php5ts!zval_add_ref+1385
php5ts!execute+1fe
php5ts!zend_execute_scripts+15a
php5ts!ts_resource_ex+14
php5ts!php_execute_script+1c5
php5ts!php_execute_script+a8
KERNELBASE!WaitForSingleObjectEx+cb
php_mbstring!mbfl_name2language+2b5
php_xsl!get_module+2ec
libapr_1!apr_pmemdup+2a
libapr_1!apr_pstrdup+29
php5apache2_4+18c7
mod_rewrite+7061
libhttpd!ap_run_handler+25
libhttpd!ap_invoke_handler+a1
libhttpd!ap_internal_redirect+36
mod_rewrite+80fa
libhttpd!ap_run_handler+25
libhttpd!ap_invoke_handler+a1
libhttpd!ap_die+39c
libhttpd!ap_die+42f
libhttpd!ap_psignature+14c8

-- 
Edit bug report at https://bugs.php.net/bug.php?id=68628&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=68628&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=68628&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=68628&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=68628&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=68628&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=68628&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=68628&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=68628&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=68628&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=68628&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=68628&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=68628&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=68628&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68628&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=68628&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=68628&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=68628&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=68628&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=68628&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=68628&r=mysqlcfg



Thread (3 messages)

« previous php.bugs (#189126) next »