国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

【PHP問題定位】修改數據庫字段導致的fpm的coredump問題定位

ASCH / 2832人閱讀

摘要:順風車運營研發團隊黃桃背景線上零星會出現進程及進程占用內存超過限制等報警告,并且兩者報警的時間上往往都比較接近,如下原因分析時間上接近,那么出現兩者報警的原因有可能是相同的,登錄機器調試生成文件

順風車運營研發團隊 黃桃

背景

線上零星會出現fpm進程coredump 及 fpm進程占用內存超過限制等報警告,并且兩者報警的時間上往往都比較接近,如下:

原因分析

時間上接近,那么出現兩者報警的原因有可能是相同的,登錄機器gdb調試coredump生成core文件:

cd /***/coresave/
gdb /***/php7/sbin/php-fpm -c core.php-fpm.12121.1528322653
bt
#0  0x0000003f0f089770 in memcpy () from /lib64/libc.so.6
#1  0x00000000006403c5 in zend_string_init (stmt=0x7f505b478380, colno=)
    at /**/**/offcial_code/php/7.0.6/php-7.0.6/Zend/zend_string.h:159
#2  pdo_mysql_stmt_describe (stmt=0x7f505b478380, colno=)
    at /**/**/offcial_code/php/7.0.6/php-7.0.6/ext/pdo_mysql/mysql_statement.c:705
#3  0x000000000063a795 in pdo_stmt_describe_columns (stmt=0x7f505b478380) at /**/**/offcial_code/php/7.0.6/php-7.0.6/ext/pdo/pdo_stmt.c:206
#4  0x000000000063add5 in zim_PDOStatement_execute (execute_data=, return_value=0x7f505b4157e0)
    at /**/**/offcial_code/php/7.0.6/php-7.0.6/ext/pdo/pdo_stmt.c:523
#5  0x00007f5054056bf1 in hp_execute_internal (execute_data=0x7f505b415830, return_value=0x7f505b4157e0) at /**/**/xhprof/extension/xhprof.c:1775
#6  0x0000000000879702 in ZEND_DO_FCALL_SPEC_HANDLER (execute_data=0x7f505b415680)
    at /**/**/offcial_code/php/7.0.6/php-7.0.6/Zend/zend_vm_execute.h:844
#7  0x0000000000841a40 in execute_ex (ex=) at /**/**/offcial_code/php/7.0.6/php-7.0.6/Zend/zend_vm_execute.h:417
#8  0x00007f50540583d1 in hp_execute_ex (execute_data=0x7f505b415680) at /**/**/xhprof/extension/xhprof.c:1748
#9  0x000000000087957a in ZEND_DO_FCALL_SPEC_HANDLER (execute_data=0x7f505b4155a0)
    at /**/**/offcial_code/php/7.0.6/php-7.0.6/Zend/zend_vm_execute.h:800
#10 0x0000000000841a40 in execute_ex (ex=) at /**/**/offcial_code/php/7.0.6/php-7.0.6/Zend/zend_vm_execute.h:417
#11 0x00007f50540583d1 in hp_execute_ex (execute_data=0x7f505b4155a0) at /**/**/xhprof/extension/xhprof.c:1748
#12 0x000000000087957a in ZEND_DO_FCALL_SPEC_HANDLER (execute_data=0x7f505b4154a0)
    at /**/**/offcial_code/php/7.0.6/php-7.0.6/Zend/zend_vm_execute.h:800
#13 0x0000000000841a40 in execute_ex (ex=) at /**/**/offcial_code/php/7.0.6/php-7.0.6/Zend/zend_vm_execute.h:417
#14 0x00007f50540583d1 in hp_execute_ex (execute_data=0x7f505b4154a0) at /**/**/xhprof/extension/xhprof.c:1748
#15 0x000000000087957a in ZEND_DO_FCALL_SPEC_HANDLER (execute_data=0x7f505b4153b0)
    at /**/**/offcial_code/php/7.0.6/php-7.0.6/Zend/zend_vm_execute.h:800
#16 0x0000000000841a40 in execute_ex (ex=) at /**/**/offcial_code/php/7.0.6/php-7.0.6/Zend/zend_vm_execute.h:417
#17 0x00007f50540583d1 in hp_execute_ex (execute_data=0x7f505b4153b0) at /**/**/xhprof/extension/xhprof.c:1748
#18 0x00000000007f52a8 in zend_call_function (fci=0x7ffebd295f40, fci_cache=0x7ffebd295f90)
    at /**/**/offcial_code/php/7.0.6/php-7.0.6/Zend/zend_execute_API.c:866
#19 0x0000000000709fef in zif_call_user_func_array (execute_data=0x7f505b415330, return_value=0x7f505b415300)
    at /**/**/offcial_code/php/7.0.6/php-7.0.6/ext/standard/basic_functions.c:4811
#20 0x00007f5054056bf1 in hp_execute_internal (execute_data=0x7f505b415330, return_value=0x7f505b415300) at /**/**/xhprof/extension/xhprof.c:1775
#21 0x0000000000879702 in ZEND_DO_FCALL_SPEC_HANDLER (execute_data=0x7f505b415290)
    at /**/**/offcial_code/php/7.0.6/php-7.0.6/Zend/zend_vm_execute.h:844
#22 0x0000000000841a40 in execute_ex (ex=) at /**/**/offcial_code/php/7.0.6/php-7.0.6/Zend/zend_vm_execute.h:417
---Type  to continue, or q  to quit---
#23 0x00007f50540583d1 in hp_execute_ex (execute_data=0x7f505b415290) at /**/**/xhprof/extension/xhprof.c:1748
#24 0x000000000087957a in ZEND_DO_FCALL_SPEC_HANDLER (execute_data=0x7f505b4150f0)
    at /**/**/offcial_code/php/7.0.6/php-7.0.6/Zend/zend_vm_execute.h:800
#25 0x0000000000841a40 in execute_ex (ex=) at /**/**/offcial_code/php/7.0.6/php-7.0.6/Zend/zend_vm_execute.h:417
#26 0x00007f50540583d1 in hp_execute_ex (execute_data=0x7f505b4150f0) at /**/**/xhprof/extension/xhprof.c:1748
#27 0x0000000000887037 in ZEND_INCLUDE_OR_EVAL_SPEC_TMPVAR_HANDLER (execute_data=0x7f505b415030)
    at /**/**/offcial_code/php/7.0.6/php-7.0.6/Zend/zend_vm_execute.h:40848
#28 0x0000000000841a40 in execute_ex (ex=) at /**/**/offcial_code/php/7.0.6/php-7.0.6/Zend/zend_vm_execute.h:417
#29 0x00007f50540583d1 in hp_execute_ex (execute_data=0x7f505b415030) at /**/**/xhprof/extension/xhprof.c:1748
#30 0x000000000089496b in zend_execute (op_array=0x7f505b46a000, return_value=)
    at /**/**/offcial_code/php/7.0.6/php-7.0.6/Zend/zend_vm_execute.h:458
#31 0x0000000000802233 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /**/**/offcial_code/php/7.0.6/php-7.0.6/Zend/zend.c:1427
#32 0x00000000007a4b40 in php_execute_script (primary_file=0x7ffebd298990) at /**/**/offcial_code/php/7.0.6/php-7.0.6/main/main.c:2494
#33 0x00000000008a27fe in main (argc=, argv=)
    at /**/**/offcial_code/php/7.0.6/php-7.0.6/sapi/fpm/fpm/fpm_main.c:1968

可以看到是在調用pdo擴展讀取MySQL數據后,然后copy讀取到的數據(memcpy)時出現的coredump

通過php的gdb工具.gdbint,來查看對應的zbacktrace

source /tmp/php-src-PHP-7.0.6/.gdbinit
zbacktrace
[0x7f505b415830] PDOStatement->execute(array(1)[0x7f505b415890]) [internal function]
[0x7f505b415680] ******Mysql->run("SELECT40*40FROM40table_name40WHERE4040user_id40=40?", array(1)[0x7f505b4156f0], "select") /**/**/**/**/helper/mysql.php:270
[0x7f505b4155a0] ******Mysql->select("table_name", "40user_id40=40?40", array(1)[0x7f505b415620]) /**/**/**/**/helper/mysql.php:364
[0x7f505b4154a0] ******ModelUserFaceAuth->getInfoByUidForApi("144796772") /**/**/**/**/model/user/faceauth.php:200
[0x7f505b4153b0] ******ControllerUserFaceAuthInfo->index(array(2)[0x7f505b415410]) /**/**/***/***/controller/user/faceauthinfo.php:50
[0x7f505b415330] call_user_func_array(array(2)[0x7f505b415390], array(1)[0x7f505b4153a0]) [internal function]
[0x7f505b415290] ***FrameworkBaseRouter->run(array(2)[0x7f505b4152f0]) /**/**/**/**/base/router.php:96
[0x7f505b4150f0] (main) /**/**/**/**/framework.php:139
[0x7f505b415030] (main) /**/**/***/***/index.php:46

是在執行“SELECT40*40FROM40table_name40WHERE4040user_id40=40? ”出現的問題

此時兩種可能,第一個傳入的參數是否有問題?第二個是此語句返回的數據是否有問題?

先驗證傳入參數:

繼續看當時傳入的參數是什么?打印地址 0x7f505b415620 當時的值

(gdb) print ((zval *)0x7f505b415620)
$1 = (zval *) 0x7f505b415620
(gdb) p $1
$2 = (zval *) 0x7f505b415620
(gdb) p *$1
$3 = {value = {lval = 139983105408624, dval = 6.9160843380575109e-310, counted = 0x7f505b45be70, str = 0x7f505b45be70, arr = 0x7f505b45be70,
    obj = 0x7f505b45be70, res = 0x7f505b45be70, ref = 0x7f505b45be70, ast = 0x7f505b45be70, zv = 0x7f505b45be70, ptr = 0x7f505b45be70, ce = 0x7f505b45be70,
    func = 0x7f505b45be70, ww = {w1 = 1531297392, w2 = 32592}}, u1 = {v = {type = 7 "a", type_flags = 28 "