php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55334 MySQLi make mod_php crash on stress test
Submitted: 2011-08-01 09:16 UTC Modified: 2012-05-04 10:08 UTC
Votes:9
Avg. Score:4.8 ± 0.4
Reproduced:8 of 8 (100.0%)
Same Version:4 (50.0%)
Same OS:4 (50.0%)
From: bruno at chalopin dot fr Assigned: mattficken (profile)
Status: Closed Package: MySQLi related
PHP Version: 5.3.7RC4 OS: Windows 2008r2 x64
Private report: No CVE-ID: None
 [2011-08-01 09:16 UTC] bruno at chalopin dot fr
Description:
------------
mod_php crashes on stress test (ab -n 10000 -c 20) due to MySqli (the use of the mysql extension don't make it crash)

Test script:
---------------
<h1>Test MySqli</h1>
<ul>
<?php
$con = mysqli_connect('127.0.0.1', 'root', 'secret', 'test');

$stmt = mysqli_query($con, 'SELECT * FROM test');

while($row = mysqli_fetch_array($stmt, MYSQLI_ASSOC))
{
	echo '<li>' . $row['id'] . ' - ' . $row['data'] . '</li>';
}

?>
</ul>

Actual result:
--------------
Type of Analysis Performed   Crash Analysis 
Machine Name   CHALOPIN-2008R2 
Operating System   Unexpected Service Pack 1 
Number Of Processors   8 
Process ID   3444 
Process Image   D:\SysperTec\webstack\Apache2\bin\httpd.exe 
System Up-Time   01:19:31 
Process Up-Time   00:00:01 


Thread 16 - System ID 3560
Entry point   msvcr90!_endthreadex+6f 
Create time   01/08/2011 10:35:10 
Time spent in user mode   0 Days 0:0:0.0 
Time spent in kernel mode   0 Days 0:0:0.0 

Function     Arg 1     Arg 2     Arg 3   Source 
php5ts!zend_register_internal_class_ex+b77     04ae90a0     6f21e664     016b02f0    
php5ts!_efree+2e     016b02f0     0544ed20     6f223957    
php5ts!_zval_ptr_dtor+54     0544f01c     0544ef50     0544f2b8    
php5ts!zend_hash_destroy+27     0544dbe0     04a94b58     72451201    
php5ts!zend_object_std_dtor+2b     0544f2b8     04a94b58     05442e4c    
php_mysqli!php_clear_mysql+d1     0544f2b8     04a94b58     04a94b58    
php5ts!zend_objects_store_del_ref_by_handle_ex+1c1     00000001     72465600     04a94b58    
php5ts!zend_objects_store_del_ref+1a     0544e8b0     04a94b58     00000000    
php5ts!_zval_dtor_func+7f     0544e8b0     0544dce0     6f223ad2    
php5ts!_zval_ptr_dtor+4b     0544dcec     6f223d83     04a94b58    
php5ts!zend_hash_clean+112     04a94b58     0262fa9c     0262fa8c    
php5ts!zend_hash_reverse_apply+53     04ae7218     6f21deb0     04a94b58    
php5ts!shutdown_destructors+77     04a94b58     04a94b58     0262fae0    
php5ts!zend_call_destructors+42     04a94b58     04a94b58     00000000    
php5ts!php_request_shutdown+f0     00000000     00000004     0156df20    
php5apache2_2!zm_info_apache+1801     01d55f30     01d55f30     00cfb3e8    
libhttpd!ap_run_handler+25     00000000     00000000     00000000    

PHP5TS!ZEND_REGISTER_INTERNAL_CLASS_EX+B77In httpd__PID__3444__Date__08_01_2011__Time_10_35_10AM__368__Second_Chance_Exception_C0000005.dmp the assembly instruction at php5ts!zend_register_internal_class_ex+b77 in d:\SysperTec\webstack\php\php5ts.dll from The PHP Group has caused an access violation exception (0xC0000005) when trying to read from memory location 0x3c7edce0 on thread 16

Module Information 
Image Name: d:\SysperTec\webstack\php\php5ts.dll   Symbol Type:  PDB 
Base address: 0x6f190000   Time Stamp:  Thu Jul 28 14:38:06 2011  
Checksum: 0x005b1351   Comments:   
COM DLL: False   Company Name:  The PHP Group 
ISAPIExtension: False   File Description:  PHP Script Interpreter 
ISAPIFilter: False   File Version:  5.3.7RC4 
Managed DLL: False   Internal Name:  PHP Script Interpreter 
VB DLL: False   Legal Copyright:  Copyright © 1997-2010 The PHP Group 
Loaded Image Name:  php5ts.dll   Legal Trademarks:  PHP 
Mapped Image Name:     Original filename:  php5ts.dll 
Module name:  php5ts   Private Build:   
Single Threaded:  False   Product Name:  PHP 
Module Size:  5,76 MBytes   Product Version:  5.3.7RC4 
Symbol File Name:  D:\SysperTec\webstack\php-debug\php5ts.pdb   Special Build:  &

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-02 07:40 UTC] bruno at chalopin dot fr
More informations :

The test database :
-------------------

CREATE TABLE `test` (
  `id` int(11) NOT NULL,
  `data` text COLLATE latin1_general_ci,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

INSERT  INTO `test`(`id`,`data`) VALUES (1,'foo'),(2,'bar'),(3,'gru');

Software version :
------------------

MySql 5.5.14 x86
Apache 2.2.19 x86 VC9 (from apachelounge)

Both have default conf file.
 [2011-10-21 14:47 UTC] doug at sevone dot com
I have been able to reproduce a similar (if not the same) crash by this SIMPLER 
script:

<?php
mysqli_init();
?>

On another machine, I have about 12 threads doing GET requests to that page 
simultaneously.  I usually see a crash after about 1-2 seconds.

As far as I can tell, this is a "mysqli" issue only (involving thread-safety).  
If I disable mysqlnd, then I still see the same problem.  I see this on MySQL 
5.5 and 5.1.  However, the MySQL version should NOT matter, since I can 
reproduce the problem without EVER connecting to a MySQL box, and since it 
crashes using mysqlnd.

OS: gentoo (x86_64)
Apache: www-servers/apache-2.2.14-r1
Apache: www-servers/apache-2.2.21
PHP: dev-lang/php-5.3.6
PHP: dev-lang/php-5.3.8
 [2012-01-19 07:40 UTC] ninzya at inbox dot lv
Got apache crashing due to MySQLi as well. Here's the bug report: 
https://bugs.php.net/bug.php?id=55334
 [2012-03-08 12:52 UTC] johannes@php.net
Automatic comment from SVN on behalf of johannes
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=324022
Log: Use correct property ctor, should fix threading issue in bug #55334
# The code was refactored in 5_4/trunk, no need to merge
 [2012-03-08 12:55 UTC] johannes@php.net
-Status: Open +Status: Feedback
 [2012-03-08 12:55 UTC] johannes@php.net
Seems like this was a bug from very old times in mysqli. I've applied a fix to PHP_5_3 and couldn't trigger an issue anymore with lots of concurrency over a longer period.
A fix for 5.4 and trunk is not needed as the code had been refactored before. Please run your tests, too.
 [2012-03-08 13:08 UTC] johannes@php.net
-Status: Feedback +Status: Assigned -Assigned To: +Assigned To: mattficken
 [2012-03-08 13:08 UTC] johannes@php.net
13:58 <@johannes> Pierre: can you check 5.3 in your stress tests regarding 55334? On Linux and Solaris I can't hit it in threaded context anymore. 5.4/trunk seems to be fixed by dmitry's property refactoring work (svn r299692)
14:05 <@Pierre> johannes, add a comment to the bug and assign it to matt.
 [2012-03-09 00:02 UTC] mattficken@php.net
Using apache bench locally, I can reproduce this bug on php 5.3.10 and php 5.4.0 using just mysqli.
 [2012-03-09 09:52 UTC] johannes@php.net
For 5.3 please use svn snaps. Can you share more details on the test you're doing and the effects you see?
 [2012-03-09 19:03 UTC] mattficken@php.net
Using 5_3 r324027, with Apache 2.2 on Windows 2008r2sp0, I can no longer reproduce this bug.


I think this bug is fixed.
 [2012-03-09 19:07 UTC] mattficken@php.net
-Status: Assigned +Status: Closed
 [2012-03-09 19:07 UTC] mattficken@php.net
Closing bug
 [2012-03-09 23:08 UTC] mattficken@php.net
-Status: Closed +Status: Re-Opened
 [2012-03-09 23:08 UTC] mattficken@php.net
To repro this problem, your test environment needs to have 4+ cpus, which the environment I was previously using didn't have.
 [2012-03-12 17:21 UTC] pajoye@php.net
-Status: Re-Opened +Status: Assigned -Assigned To: mattficken +Assigned To: johannes
 [2012-03-12 17:21 UTC] pajoye@php.net
Johannes,

See last comment, I can also still reproduce it locally (dual quad).
 [2012-04-08 22:19 UTC] ricardo dot nuno dot rodrigues at hotmail dot com
Hi there,

In PHP 5.4 TS VC9 (Win) I have the same problem. Under stress goes down.

With file mysql_test.php:
<?php
mysqli_init();
?>

Under:
ab -n 10000 -c 50 http://127.0.0.1/mysql_test.php

It restart server (apache 2.2.21). Sometimes creates a delay. Under xdebug 
there's a big time to 
connect.

Thanks
Ricardo
 [2012-05-02 09:47 UTC] johannes@php.net
-Assigned To: johannes +Assigned To: mattficken
 [2012-05-02 09:47 UTC] johannes@php.net
Matt, can you give it a new run. The change http://git.php.net/?p=php-src.git;a=commit;h=ea3e0d5a7370df63af9372780b91a749fda773b1 which is in 5.4.1 should fix the issue for 5.4. See also http://news.php.net/php.internals/59353

I wasn't able to see an issue neither in 5.3 nor 5.4 after having a 64-way Solaris machine running for a few hours. For Windows I did only a shorter test on a 4-way machine.
 [2012-05-03 20:32 UTC] mattficken@php.net
johannes, your patch works for me with 5.4.1 on a 4-way and an 8-way windows 2008r2 server with:
ab -n 10000 -c 20
ab -n 100000 -c 20
ab -n 100000 -c 50
and ab -n 10000 -c 50.
 [2012-05-04 09:02 UTC] uw@php.net
So, this can be closed?
 [2012-05-04 10:08 UTC] johannes@php.net
-Status: Assigned +Status: Closed
 [2012-05-04 10:08 UTC] johannes@php.net
Closing after different verifications.
 [2012-05-05 18:28 UTC] ricardo dot nuno dot rodrigues at hotmail dot com
Can you check if are related since found that is mysqlnd creating problems?

https://bugs.php.net/bug.php?id=61704&edit=2
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 20:01:29 2024 UTC