使用gdb调试php代码,解决php代码死循环问题

使用gdb调试php代码,解决php代码死循环问题

ID:32632249

大小:95.22 KB

页数:10页

时间:2019-02-13

使用gdb调试php代码,解决php代码死循环问题_第1页
使用gdb调试php代码,解决php代码死循环问题_第2页
使用gdb调试php代码,解决php代码死循环问题_第3页
使用gdb调试php代码,解决php代码死循环问题_第4页
使用gdb调试php代码,解决php代码死循环问题_第5页
资源描述:

《使用gdb调试php代码,解决php代码死循环问题》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、使用GDB调试PHP代码,解决PHP代码死循环问题最近在帮同事解决SwooleServer问题时,发现有1个worker进程一直处于R的状态,而且CPU耗时非常高。初步断定是PHP代码中发生死循环。下面通过一段代码展示如何解决PHP死循环问题。代码如下:#dead_loop・php$array=array();for($i=0;$ilt:10000;$i++){$array[]=$i;}include_DIR_・"/include・php";#include.phpwh订e(1){usleep(lO);$keys=arra

2、y_flip($array);$index=array_search(rand(1500,9999),$array);$str=str_repeat('A',$index);$strb=test($index,$str);functiontest($index,$str)returnstr_replaceCA','B',$str);}通过psaux得到进程ID和状态如下,使用gdb-p进程ptrace跟踪,通过bt命令得到调用栈代码如下:htf38342.60.216667622060pts/12R+10:500:12ph

3、pdeadloop・phpgdb~p3834(gdb)bt#00x00000000008cc03finzend_mm_checkptr(heap=0xleaa2c0,ptr=0x2584910,silent二1,_zend_filename=0xee3d40〃/home/htf/workspace/php-5.4.27/Zend/zendvariables・c"、_zend_lineno二182,_zendorig_filename=0xeel888〃/home/htf/workspace/php-5・4.27/Zend/

4、zend_execute_API._zend_orig_lineno=437)at/home/htf/workspace/php-5.4.27/Zend/zend_alloc・c:1485#10x00000000008cd643inzendmmfreeint(heap=0xleaa2cO,p=0x2584910,_zend_filename=0xee3d40/z/home/htf/workspace/php-5・4.27/Zend/zendvariables.zendlineno=182,zend_orig_filenam

5、e=0xeel888z//home/htf/workspace/php-5.4.27/Zend/zendexecuteAPI.c"、zendorig_lineno=437)at/home/htf/workspace/php-5・4.27/Zend/zendalloc・c:2064#20x00000000008cebf7in_efree(ptr=0x2584910,zendfilename=0xee3d40/z/home/htf/workspace/php-5・4.27/Zend/zendvariables.zendline

6、no二182,zendMMorig_filename=0xeel888z//home/htf/workspace/php-5.4.27/Zend/zend_execute_API.c"、zendorig_linenoM37)at/home/htf/workspace/php-5・4.27/Zend/zendalloc・c:2436#30x00000000008edaOain_zval_ptr_dtor(zval_ptr=0x25849a0,_zend_filename=0xee3d407home/htf/workspace

7、/php-5.4.27/Zend/zend_variables.c〃,_zend_lineno=182)at/home/htf/workspace/php-5・4.27/Zend/zend_execute_API.c:437#40x00000000008fe687in_zval_ptr_dtor_wrapper(zval_ptr=0x25849a0)at/home/htf/workspace/php-5.4.27/Zend/zend_variables・c:182#50x000000000091259finzendhash

8、destroy(ht=0x7f7263f6e380)at/home/htf/workspace/php-5.4.27/Zend/zendhash.c:560#60X00000000008fe2c5in_zval_dtor_func(zvalue=0x7f726426fe50,_zend_filename

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。