【gdb】对Linux的软件debug方法


【gdb】对Linux的软件debug方法

https://blog.csdn.net/niyaozuozuihao/article/details/91802994

AH00052: child pid xxxx exit signal Segmentation fault (11) 解决办法
主题 signal
推荐:[web服务器]APACHE日志child pid XXXXXX exit signal Segmentation fault (11)解决

[近日新开的vps都是centos6的,按照往常一样配置好web服务器,如下:httpd/2.2.15php/5.3.3 with eAccelerator with Zend Guard Loader v3.3修改好apache配置文件后,习惯

今天在修改一个 apache 模块,测试时出现了这个问题,由于加载的模块较多,无法确认具体是那个模块出了问题。由错误描述可以看出 是段错误,因此可以通过调试解决

首先查找当前httpd 的进程:

# ps -ef|grep httpd
root      6353     1  0 09:58 ?        00:00:00 /usr/local/apache/bin/httpd -k graceful
daemon    7941  6353  0 10:26 ?        00:00:00 /usr/local/apache/bin/httpd -k graceful
daemon    7942  6353  0 10:26 ?        00:00:00 /usr/local/apache/bin/httpd -k graceful
daemon    7943  6353  0 10:26 ?        00:00:00 /usr/local/apache/bin/httpd -k graceful
root      8028  3227  0 10:26 pts/0    00:00:00 grep httpd

然后使用gdb 附加到其中一个进程上(第二列是进程ID)

#gdb

GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6_4.1)
Copyright © 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type “show copying”
and “show warranty” for details.
This GDB was configured as “i686-redhat-linux-gnu”.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/.

(gdb)attach 7943

Attaching to process 7943
Reading symbols from /usr/local/apache/bin/httpd…done.
Reading symbols from /usr/local/lib/libpcre.so.1…done.
Loaded symbols for /usr/local/lib/libpcre.so.1

推荐:解决 child pid exit signal segmentation fault 11

[解决 child pid exit signal segmentation fault 11]

(gdb) c
Continuing.

在这里向服务器发起一个连接

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb6bffb70 (LWP 7947)]
0x0018a4de in vfprintf () from /lib/libc.so.6
从上述信息可以看到程序被中断在库函数 vfprintf()中

使用gdb backtrace命令可以查看 当前的函数调用栈的所有信息

(gdb) backtrace

#0 0x0018a4de in vfprintf () from /lib/libc.so.6
#1 0x001b19b0 in vsnprintf () from /lib/libc.so.6
#2 0x0030948f in mod_writelog (cstrFormat=0x30a5a4 “begin find:%s\n”) at mod_evasive20.c:130
#3 0x0030977a in ntt_find (ntt=0x9b48c88, key=0xb6bfdf80 “WHITELIST_192.168.168.29”) at mod_evasive20.c:533
#4 0x00309bb1 in is_whitelisted (ip=0xb6c35b50 “192.168.168.29”) at mod_evasive20.c:435
#5 0x00309d30 in access_checker (r=0xa66024c8) at mod_evasive20.c:237
#6 0x0807e2bd in ap_run_access_checker (r=0xa66024c8) at request.c:85
#7 0x08080cfc in ap_process_request_internal (r=0xa66024c8) at request.c:218
#8 0x0809c800 in ap_process_async_request (r=0xa66024c8) at http_request.c:315
#9 0x080992d6 in ap_process_http_async_connection (c=0xb6c35900) at http_core.c:143
#10 ap_process_http_connection (c=0xb6c35900) at http_core.c:228
#11 0x08090e0e in ap_run_process_connection (c=0xb6c35900) at connection.c:41
#12 0x080a5a6f in process_socket (thd=0x9b27018, dummy=0xb6c00468) at event.c:964
#13 worker_thread (thd=0x9b27018, dummy=0xb6c00468) at event.c:1812
#14 0x00ecd926 in dummy_worker (opaque=0x9b27018) at threadproc/unix/thread.c:142
#15 0x002eea49 in start_thread () from /lib/libpthread.so.0
#16 0x0022aaae in clone () from /lib/libc.so.6

由程序崩溃处的函数调用栈信息可以很快定位到出错的位置(红色区域 我的程序出错的信息)。

然后就可以使用gdb调试出错的模块,调试apache模块的方法可参考:

https://blog.csdn.net/greatchina01/article/details/11613305

1.停止apache服务
#apachectl -k stop
2.#gdb httpd    (这里指apache/bin/httpd)
3.设置断点等操作 
4.#run -X
5.向服务器发送连接,即可触发断点

推荐:child pid xxxxx exit signal Segmentation fault (11)

[ Apache的error_log: [Wed Jun 01 14:59:05 2011] [notice] child pid 28198 exit signal Segmentation fault (11) [Wed Jun 01 15:00:03 2011] [notice] child pi

http://www.itboth.com/d/jmYvMf/signal

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值