1. 程式人生 > >nginx錯誤日誌出現worker process 24939 exited on signal 11 (core dumped)

nginx錯誤日誌出現worker process 24939 exited on signal 11 (core dumped)

今天發現用google瀏覽器訪問nginx伺服器時,部分檔案請求無法正常載入,導致頁面顯示不正常。檢視nginx錯誤日誌,出現了大量這樣的資料:

2015/04/22 13:31:59 [alert] 13175#0: worker process 2703 exited on signal 11 (core dumped)
2015/04/22 13:31:59 [alert] 13175#0: worker process 2711 exited on signal 11 (core dumped)
2015/04/22 13:31:59 [alert] 13175#0: worker process 2716 exited on signal 11 (core dumped)
2015/04/22 13:31:59 [alert] 13175#0: worker process 2721 exited on signal 11 (core dumped)
2015/04/22 13:32:00 [alert] 13175#0: worker process 2634 exited on signal 11 (core dumped)
2015/04/22 13:32:00 [alert] 13175#0: worker process 2725 exited on signal 11 (core dumped)
2015/04/22 13:32:01 [alert] 13175#0: worker process 2734 exited on signal 11 (core dumped)

檢視dmesg也發現了錯誤  

#dmesg

nginx[2703]: segfault at 359 ip 000000000043f2b6 sp 00007fff7071ef40 error 4 in nginx[400000+94b000]
nginx[2711]: segfault at 359 ip 000000000043f2b6 sp 00007fff7071ef40 error 4 in nginx[400000+94b000]
nginx[2716]: segfault at 359 ip 000000000043f2b6 sp 00007fff7071ef40 error 4 in nginx[400000+94b000]
nginx[2721]: segfault at 359 ip 000000000043f2b6 sp 00007fff7071ef40 error 4 in nginx[400000+94b000]
nginx[2725]: segfault at 359 ip 000000000043f2b6 sp 00007fff7071ef40 error 4 in nginx[400000+94b000]
nginx[2734]: segfault at 359 ip 000000000043f2b6 sp 00007fff7071ef40 error 4 in nginx[400000+94b000]

這種資訊一般都是由核心記憶體訪問越界造成的,不管是使用者態程式還是核心態程式訪問越界都會出core,並在系統日誌裡面輸出一條這樣的資訊。這條資訊的前面分別是訪問越界的程式名,程序id號,訪問越界的地址以及當時程序程序堆疊地址等資訊,比較有用的資訊是最後的error number.在上面的資訊中,error number 是4。下面詳細介紹一下error number的資訊:


在上面的例子中,error number是4,轉成二進位制就是100,即bit2=1,bit1=0,bit0=0


error number是由3個字位組成的,從高到低分別是bit2、bit1、bit0,所以它的取值範圍是0~7


bit2:值為1時表示 是使用者態程式記憶體訪問越界,值為0時表示 是核心態程式記憶體訪問越界
bit1:值為1時表示 是寫操作導致記憶體訪問越界,值為0時表示 是讀操作導致記憶體訪問越界
bit0:值為1表示沒有足夠的許可權訪問非法地址的內容,值為0時表示訪問的非法地址根本沒有對應的頁面,也就是無效地址。


所以error 4 就表示使用者態程式nginx進行讀操作時訪問的地址無效。

那麼問題怎麼解決呢?幸好找到了這篇文章:http://blog.csdn.net/xuyaqun/article/details/5343021。作者遇到的情況跟我的很相似。

原來是搜尋引擎的蜘蛛在爬取到加密部分時,得不到正確的路徑,又沒有被定位到錯誤頁導致的。

附:段錯誤 segfault 是什麼
段錯誤是指訪問的記憶體超出了系統給這個程式所設定的記憶體空間,例如訪問了不存在的記憶體地址,訪問了系統保護的記憶體地址,訪問了只讀的記憶體地址等等情況。這裡貼出一個對“段錯誤的準確定義”(參考Answers.com)


A segmentation fault (often shortened to segfault) is a particular error condition that can occur during the operation of computer software. In short, a segmentation fault occurs when a program attempts to access a memory location that it is not allowed to access, or attempts to access a memory location in a way that is not allowed (e.g., attempts to write to a read-only location, or to overwrite part of the operating system). Systems based on processors like the Motorola 68000 tend to refer to these events as Address or Bus errors.
Segmentation is one approach to memory management and protection in the operating system. It has been superseded by paging for most purposes, but much of the terminology of segmentation is still used, "segmentation fault" being an example. Some operating systems still have segmentation at some logical level although paging is used as the main memory management policy.
On Unix-like operating systems, a process that accesses invalid memory receives the SIGSEGV signal. On Microsoft Windows, a process that accesses invalid memory receives the STATUS_ACCESS_VIOLATION exception.