php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50551 mb_ereg + mb_eregi crash
Submitted: 2009-12-22 00:37 UTC Modified: 2013-02-18 00:34 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: r dot badding at gmail dot com Assigned:
Status: No Feedback Package: mbstring related
PHP Version: 5.2.12 OS: win32 only - Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: r dot badding at gmail dot com
New email:
PHP Version: OS:

 

 [2009-12-22 00:37 UTC] r dot badding at gmail dot com
Description:
------------
When I make two request to the attached php file, in close proximity (so 
that the requests run at the same time), PHP crashes every time.

If I modify the php file so that there are two mb_ereg calls, instead of 
one mb_ereg + one mb_eregi, I seem to get no crashes.

Reproduce code:
---------------
<?

	for ($i = 0; $i < 5000000; $i++)
	{
		mb_ereg("searching", "some text some text");
		mb_eregi("searching", "some text some text");
	}

?>

Expected result:
----------------
No crashes.

Actual result:
--------------
Crash.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-22 00:45 UTC] r dot badding at gmail dot com
I used a "clean" install, thread safe package. only mbstring extension 
enabled, "recommended" ini file.
 [2009-12-22 00:57 UTC] r dot badding at gmail dot com
Also I used these
Apache/2.0.63 (Win32) 
Server API	Apache 2.0 Handler

(cannot edit this bug submission, "incorrect password")
 [2009-12-22 09:05 UTC] jani@php.net
Please define "crash" ? Aren't you just running out of stack or memory..? FYI: There is no crash on *nix..
 [2009-12-22 09:05 UTC] jani@php.net
And regarding the password, you can find the password reminder link on the "Edit Submission" tab..
 [2009-12-22 15:00 UTC] r dot badding at gmail dot com
By crash, I mean a dialog box like this:

---------------------------
Visual Studio Just-In-Time Debugger
---------------------------
An unhandled win32 exception occurred in Apache.exe [4804]. Just-In-
Time 
debugging this exception failed with the following error: No installed 
debugger has Just-In-Time debugging enabled. In Visual Studio, Just-
In-
Time debugging can be enabled from Tools/Options/Debugging/Just-In-
Time.

Check the documentation index for 'Just-in-time debugging, errors' for 
more information.
---------------------------
OK   
---------------------------


When I have eAccelerator enabled, instead of the dialog box I get 
these 
into the Apache's error.log:
EACCELERATOR: PHP crashed on opline 7 of mb_ereg()

Sure, the error might be in somewhere else than in php, maybe in 
Apache, 
or the api dll or anywhere...
 [2009-12-30 13:42 UTC] r dot badding at gmail dot com
So, nobody can reproduce? The testcase is simple at least...
 [2009-12-30 14:43 UTC] jani@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

Try the snap. Maybe it was fixed as I can't reproduce this. And when you reply, use the "Edit submission" tab!
 [2010-01-02 17:04 UTC] r dot badding at gmail dot com
Still getting the same crash with the snapshot php-5.2-win32-VC6-x86-
latest.

I made sure I had the correct extension dir in php.ini and no other 
php5ts.dll were found than the one in the snapshot. 

I think I haven't screwed up anything, but of course there's always that 
possibility. Don't think so though.
 [2010-08-12 00:19 UTC] kalle@php.net
-Status: Open +Status: Feedback
 [2010-08-12 00:19 UTC] kalle@php.net
Have you tried on 5.3? I cannot reproduce it trunk and Vista x86 with memory_limit=128MB and configure --enable-mbstring --enable-mbregex (no backtrack stack)
 [2011-09-20 07:58 UTC] webmaster at bluesting dot co dot za
I have had very similar issues! At first I never noticed mb_ereg issues or crashes, until I started running some apache benchmarks on unrelated code to simulate server load, and noticed strange crashes. I eventually isolated the crashes to mb_ereg related code. To benchmark code with Apache Benchmark, I was using the "ab" command under apache/bin directory like this:

ab -t 30 -c 10 http://localhost/

With some mb_ereg code running in the very beginning (doing url detection). The actual code is actually not important because I get crashes with every combination I try! I think using Apache Benchmark is better than running this code in a loop because it will create 10 simultaneous connections simulating higher load instead of just the one connection. When I convert my code to use preg_match_all() ... I have NO issues! Only mb_ereg related functions causing crashes! I tried mb_ereg() and mb_ereg_search_init() + mb_ereg_search_regs() with the same unpredictable crashes!

Try the code above with Apache Benchmark and the commands I gave above, you should definately be able to simulate this issue!
 [2011-09-20 08:40 UTC] pajoye@php.net
@webmaster at bluesting dot co dot za

Please provide a small reproduce script for the crashes you are experiencing. It 
could be due to something totally different. Also be sure to use 5.3.8 or snaps.
 [2011-09-20 09:36 UTC] webmaster at bluesting dot co dot za
So I was worried that it was my version as I was using 5.2.14, I have now also tested 5.2.17 and 5.3.8 with the same results!

I have disabled all extentions except: extension=php_mbstring.dll
And I have tested the code on 2 different machines, an AMD and an Intel.
Apache 2.0 and 2.2.

index.php
<?php echo mb_ereg('^/', $_SERVER['REQUEST_URI']);


Running this line once as normal in your browser, there are no issues! But once you run this line with Apache Benchmark, Apache/PHP will crash. Now it's possible that it's Apache, however I have run multiple benchmarks on all kinds of code without crashes and on 2 different versions of Apache, only this single line of code keeps crashing PHP/Apache. If I convert the code to preg_match() or preg_match_all() I have no issues!

To run Apache Benchmarks on this code, use:

ab -t 30 -c 10 http://localhost/

Note: "ab" is found in your Apache "bin" directory.

This will run the benchmark for 30 seconds with 10 concurrent connections: In "ab" I sometimes get the following message: apr_socket_recv: An existing connection was forcibly closed by the remote host.

But this is usually after Apache/PHP has crashed! The crashes occur randomly and unpredictably. Sometimes early in the benchmark, sometimes late. Sometimes Apache crashes, sometimes it can continue normally.

PS: I've tested this now on a fresh install of the thread safe 5.3.8 (32 bit on WinXP) with no other extentions enabled in php.ini. I've also tested both Apache 2.0 and 2.2, on 2 different dev machines, an AMD & Intel machine.

If this is working for you, then try increasing the time limit and concurrent connections eg.

ab -t 180 -c 50 http://localhost/
 [2011-09-23 06:44 UTC] webmaster at bluesting dot co dot za
Bump! Can someone confirm or deny this issue please!
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 13:01:29 2024 UTC