ã¤ã³ãã©ã¨ã³ã¸ãã¢ãSegmentation fault ããªãã¨ãæ²»ãã¦ã¿ã
æ®æ®µWebãµã¼ããéç¨ãã¦ãã¦ãããã©ããããã©ãã«ã®ã²ã¨ã¤ã«ãSegmentation faultããããã¾ãã
ããã¼ï¼ãªãã500ã¨ã©ã¼ãã§ããªã¼ãªãã¦æã£ã¦ãã°ãè¦ãã¨Segmentation faultã«ãªã£ã¦ãã¨ãã¯æ»ã«ãããªãã¾ãã
ããããSegmentation faultã¯ã¡ã¢ãªä¸ã«ãããã¼ã¿ã«å¯¾ãã¦ä¸æ£ãè¡ãããã¨ãã«èµ·ãããã®ã§ã
ã¤ã³ãã©ã¨ã³ã¸ãã¢ã«ã¨ã£ã¦ã¯ãªããªãæãã ããªãã¨ããã§ãããã¾ãã
ããã§ããªãã¨ããã¦æ²»ããªãã¨ãããªããããªã®ã§
ããã¦ã©ã®ããã°ã©ã ãæªããã¦ããã©ãããããã¯èª¿ã¹ä¸ãã¦ã¿ã¾ãã
apacheã§ã®ãã°
apache + mod_perl ã§ã®ç°å¢ã§ãã
ãããªæãã§ã¨ã©ã¼ãã§ã¾ãã
#tail error_log [notice] child pid 26028 exit signal Segmentation fault (11) [notice] child pid 26029 exit signal Segmentation fault (11) [notice] child pid 26030 exit signal Segmentation fault (11) [notice] child pid 26031 exit signal Segmentation fault (11)
å®å ¨ã«æ»ãã§ã¾ããã»ãã¨ãã«ãããã¨ããããã¾ããã
coreãã¯ããã
Segmentation faultãã§ã¦ããã以ä¸ã®æ å ±ããªãã®ã§coreãã¡ã¤ã«ãåããã¦ãããã°ãã¦ããã¾ãã
ulimitè¨å®
ulimit -aãæã£ã¦ã§ãçµæã§ãcore file sizeã®å¤ã0ã®å ´åã coreãã¡ã¤ã«ã®å®¹éãå¶éããã¦ã¾ãã
$ ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 16249 max locked memory (kbytes, -l) 32 max memory size (kbytes, -m) unlimited open files (-n) 1024 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 10240 cpu time (seconds, -t) unlimited max user processes (-u) unlimited virtual memory (kbytes, -v) unlimited file locks
ãªã®ã§ãulimitã³ãã³ãã§ãã®å¤ãå¤ãã¦ããå¿
è¦ãããããã§ãããulimitã¯ããã»ã¹æ¯(pidæ¯)ã®å¤ãªã®ã§ãã°ãªãããã¨å
ã«æ»ã£ã¦ãã¾ãã¾ãã
å¤ãå¤ããã«ã¯/etc/profileãæ¸ãæããã¨ç°¡åãªã®ã§ãã¤ããã£ã¡ã§å¤ãã¦ãã¾ãã¾ãã
$ diff /etc/profile.b /etc/profile 30c30 < # ulimit -S -c 0 > /dev/null 2>&1 --- > ulimit -c unlimited > /dev/null 2>&1 $
ã-c unlimitedãã§ç¡å¶éã«
å¤æ´ãããä¸åº¦ãã°ã¢ã¦ãâãã°ã¤ã³ãã¾ãã
$ ulimit -a core file size (blocks, -c) unlimited (ç¥)
apacheã®è¨å®
apacheã¯ä¸è¡å ãã¦çµäº
CoreDumpDirectory /tmp
Coreãã¡ã¤ã«ãåãå ´æã¯é©å®ãåèµ·åãå¿ããã«
Coreãã¡ã¤ã«ã解æãã¦ã¿ã
ããã¨ã¨ã©ã¼ãåºããSegmentation faultãã§ã¦ããã°ã/tmpé
ä¸ã«coreãã¡ã¤ã«ãã§ãã¦ããã¯ãã§ãã
Coreãã¡ã¤ã«ã®è§£æã¯gdbã³ãã³ãã使ç¨ãã¾ãã
gdbã³ãã³ãã¯
gdb <commnd> -c <(core)file>
ã§ä½¿ç¨ãã¾ãã
ã¾ãå®éã«æã£ã¦ã¿ã¾ãããã
ä»åã¯apacheã§ã¨ã©ã¼ãã§ãã®ã§ä¸ã®
#gdb /usr/local/apache2/bin/httpd -c /tmp/core.30864
ãããªæãã
å®éæã¤ã¨
#gdb /usr/local/apache2/bin/httpd -c /tmp/core.30864 GNU gdb (GDB) Red Hat Enterprise Linux (7.0.1-23.el5_5.2) Copyright (C) 2009 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 "i386-redhat-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /usr/local/apache2/bin/httpd ...(no debugging symbols found)...done. Reading symbols from /lib/libm.so.6...(no debugging symbols found)...done. ......... ...... ... <ç¥>
ãããªæãã§ãã¬ã¼ã¹ãã¦ãã£ã¦ãã
<ç¥> ... ...... ......... Reading symbols from /lib/libselinux.so.1...(no debugging symbols found)...done. Loaded symbols for /lib/libselinux.so.1 Reading symbols from /lib/libsepol.so.1...(no debugging symbols found)...done. Loaded symbols for /lib/libsepol.so.1 Core was generated by `/usr/local/apache2/bin/httpd '. Program terminated with signal 11, Segmentation fault. #0 0x0061faa4 in SSL_CTX_ctrl () from /lib/libssl.so.6 (gdb)
ãããªæãã§Segmentation faultã®ã¨ã©ã¼ãçºçãã¦ã
(gdb)ã¨ããããã³ãããè¿ãã¾ãã
gdbã³ãã³ãã¯é«åº¦ãªãããã¬ã§ããã°ã©ã ãã§ãã人ã¯ãããããããã°ã§ããã®ã§ãã
ã¨ãããã
(gdb)where
ã¨æã£ã¦ã¿ã¾ããããè½ã¡ã¦ãã¨ããããããã¾ãã
ãããªæãã
(gdb) where #0 0x0061faa4 in SSL_CTX_ctrl () from /lib/libssl.so.6 #1 0xb721f6f7 in XS_Crypt__SSLeay__CTX_new (cv=0xb92a828) at SSLeay.xs:133 #2 0x0810ed51 in Perl_pp_entersub () #3 0x08108ede in Perl_runops_standard () #4 0x080bdfcb in Perl_call_sv () #5 0x08069414 in perl_call_handler () #6 0x08069b29 in perl_run_stacked_handlers () #7 0x0806b071 in perl_handler () #8 0x0808b7cb in ap_invoke_handler () #9 0x080a0cee in ?? () #10 0x0ae30fc4 in ?? () #11 0x08179e99 in ?? () #12 0xbff5f558 in ?? () #13 0x080add23 in ap_ctx_new () #14 0x080a0e4b in ap_process_request () #15 0x080963ce in ?? () #16 0x0ae30fc4 in ?? () #17 0x00000004 in ?? () #18 0x0ae30fc4 in ?? () #19 0xbff5f864 in ?? () #20 0x00000004 in ?? () #21 0x4cb7f3d2 in ?? () #22 0x00000000 in ?? () (gdb)
ã§ã¾ãããããã¡ãã£ã¨ããããããã§ããã#0ã¨#1ã¿ãã¨
#0 0x0061faa4 in SSL_CTX_ctrl () from /lib/libssl.so.6 #1 0xb721f6f7 in XS_Crypt__SSLeay__CTX_new (cv=0xb92a828) at SSLeay.xs:133
ã¨ãªã£ã¦ãã¦ããªããSSLeay.xsã§è½ã¡ã¦ãã£ã½ãã£ã¦ãããã¾ãã
xsã£ã¦ã®ã¯PerlãCã使ãããã®ã¢ã¸ã¥ã¼ã«ãªãã§ããªããããã¤ãç¯äººã£ã½ãã
ã¦ãªå ·åã§ãªãã¨ãæªããã¦ãããã°ã©ã ã¯è¦ã¤ãããã¨ãã§ãã¾ããã
ãã¨ã¯
ã»ãã¨ã¯ããã¾ã§ããããã¹ã¼ãã¼ãããã°ã¿ã¤ã ãªãã ãã©ã
æ£ç´ããã°ã©ãã¼ãããªãã¨å³ããããã¾ãã¯ç¯äººããã°ã©ã ãã¢ãããã¼ããããã
ãªã³ã³ãã¤ã«ãã¦ã¿ãã¨ããã¨æãã
ã¡ãªã¿ã«âã§ç´¹ä»ããã¨ã©ã¼ã¯cpanããææ°ã®Crypt::SSLeayãæã£ã¦ãã¦å ¥ããªãããããã£ããç´ãã¾ããã
ä¾å¤ã¨ãã¦ãããã調ã¹ããã©ã¾ã£ããåå ãããããªãã¦
ã¨ãããããµã¼ããåèµ·åãããã¨ã©ã¼ã解æ¶ããã£ã¦ãã¨ãããã¾ããã
ã¾ãããããæ¥ãããããã