2,最近在VPS上测试一个php项目,用的centos6 64位的系统装完进入管理界面 始终出错 firefox打开页面一片空白,看apache的日志是
child pid XXXX exit signal Segmentation fault (11)
手工传个phpinfo进去倒是可以执行的,这个错误造成的原因很多,多半是和内存啊模块之类的有关,仔细看了看apache和php的配置,发现php里面启用了eaccelerator,关掉重启apache后解决了。
2,最近在VPS上测试一个php项目,用的centos6 64位的系统装完进入管理界面 始终出错 firefox打开页面一片空白,看apache的日志是
child pid XXXX exit signal Segmentation fault (11)
手工传个phpinfo进去倒是可以执行的,这个错误造成的原因很多,多半是和内存啊模块之类的有关,仔细看了看apache和php的配置,发现php里面启用了eaccelerator,关掉重启apache后解决了。
3,今天在修改一个 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 (C) 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
.........
(gdb) c
Continuing.
在这里向服务器发起一个连接。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模块