如何判斷我遇到了哪個使用者限制?
同一使用者的多個會話。當其中一個達到不能再執行新程序的地步時,它們都不能,甚至該使用者的新登錄名也不能。其他使用者仍然可以正常執行新程序,包括新登錄。
通常使用者限制在limits.conf中,但它的文件說“請注意,所有限制設置都是在每次登錄時設置的。它們不是全域的,也不是永久的;僅在會話期間存在。”
我的記憶體快用完了(44GB 可用),但我不知道還有什麼可以看的。存在哪些限制會對使用相同 UID 而不是其他 UID 的所有會話產生全域影響?
於 2016 年 6 月 12 日晚上 8:45 編輯添加:
在編寫以下內容時,我意識到問題可能與 X11 有關。這個盒子上的這個使用者帳戶幾乎專門用於 GUI 應用程序。是否有一個好的基於文本的程序我可以嘗試從 bash 執行,它會使用大量資源並提供良好的錯誤消息?該框沒有達到它甚至無法執行 ls 的程度。
不幸的是,這個問題通常影響的 GUI 程序(Chrome 和 Firefox)不能很好地留下錯誤消息。Chrome 選項卡將開始顯示為空白或完全無用的“哦,快!” 錯誤。Firefox 將拒絕啟動。我設法獲得的唯一甚至部分有用的錯誤消息來自嘗試從 bash 啟動 Firefox:
[pascal@firefox ~]$ firefox --display=:0 --safe-mode Assertion failure: ((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1))) && thread (Should successfully create image decoding threads), at /builddir/build/BUILD/firefox-45.2.0/firefox-45.2.0esr/image/DecodePool.cpp:359 #01: ???[/usr/lib64/firefox/libxul.so +0x10f2165] #02: ???[/usr/lib64/firefox/libxul.so +0xa2dd2c] #03: ???[/usr/lib64/firefox/libxul.so +0xa2ee29] #04: ???[/usr/lib64/firefox/libxul.so +0xa2f4c1] #05: ???[/usr/lib64/firefox/libxul.so +0xa3095d] #06: ???[/usr/lib64/firefox/libxul.so +0xa52d44] #07: ???[/usr/lib64/firefox/libxul.so +0xa4c051] #08: ???[/usr/lib64/firefox/libxul.so +0x1096257] #09: ???[/usr/lib64/firefox/libxul.so +0x1096342] #10: ???[/usr/lib64/firefox/libxul.so +0x1dba68f] #11: ???[/usr/lib64/firefox/libxul.so +0x1dba805] #12: ???[/usr/lib64/firefox/libxul.so +0x1dba8b9] #13: ???[/usr/lib64/firefox/libxul.so +0x1e3e6be] #14: ???[/usr/lib64/firefox/libxul.so +0x1e48d1f] #15: ???[/usr/lib64/firefox/libxul.so +0x1e48ddd] #16: ???[/usr/lib64/firefox/libxul.so +0x20bf7bc] #17: ???[/usr/lib64/firefox/libxul.so +0x20bfae6] #18: ???[/usr/lib64/firefox/libxul.so +0x20bfe5b] #19: ???[/usr/lib64/firefox/libxul.so +0x21087cd] #20: ???[/usr/lib64/firefox/libxul.so +0x2108cd2] #21: ???[/usr/lib64/firefox/libxul.so +0x210aef4] #22: ???[/usr/lib64/firefox/libxul.so +0x22578b1] #23: ???[/usr/lib64/firefox/libxul.so +0x228ba43] #24: ???[/usr/lib64/firefox/libxul.so +0x228be1d] #25: XRE_main[/usr/lib64/firefox/libxul.so +0x228c073] #26: ???[/usr/lib64/firefox/firefox +0x4c1d] #27: ???[/usr/lib64/firefox/firefox +0x436d] #28: __libc_start_main[/lib64/libc.so.6 +0x21b15] #29: ???[/usr/lib64/firefox/firefox +0x449d] #30: ??? (???:???) Segmentation fault [pascal@firefox ~]$ firefox --display=:0 --safe-mode -g 1465632860286DeferredSave.extensions.jsonWARNWrite failed: Error: Could not create new thread! (resource://gre/modules/PromiseWorker.jsm:173:18) JS Stack trace: this.BasePromiseWorker.prototype._worker@PromiseWorker.jsm:173:18 < postMessage@PromiseWorker.jsm:292:9 < TaskImpl_run@Task.jsm:315:40 < Handler.prototype.process@Promise-backend.js:933:23 < this.PromiseWalker.walkerLoop@Promise-backend.js:812:7 < this.PromiseWalker.scheduleWalkerLoop/<@Promise-backend.js:746:1 < BG__finalUIStartup@nsBrowserGlue.js:770:1 < BG_observe@nsBrowserGlue.js:284:9 1465632860287addons.xpi-utilsWARNFailed to save XPI database: Error: Could not create new thread! (resource://gre/modules/PromiseWorker.jsm:173:18) JS Stack trace: this.BasePromiseWorker.prototype._worker@PromiseWorker.jsm:173:18 < postMessage@PromiseWorker.jsm:292:9 < TaskImpl_run@Task.jsm:315:40 < Handler.prototype.process@Promise-backend.js:933:23 < this.PromiseWalker.walkerLoop@Promise-backend.js:812:7 < this.PromiseWalker.scheduleWalkerLoop/<@Promise-backend.js:746:1 < BG__finalUIStartup@nsBrowserGlue.js:770:1 < BG_observe@nsBrowserGlue.js:284:9 1465632860288addons.xpi-utilsWARNFailed to save XPI database: Error: Could not create new thread! (resource://gre/modules/PromiseWorker.jsm:173:18) JS Stack trace: this.BasePromiseWorker.prototype._worker@PromiseWorker.jsm:173:18 < postMessage@PromiseWorker.jsm:292:9 < TaskImpl_run@Task.jsm:315:40 < Handler.prototype.process@Promise-backend.js:933:23 < this.PromiseWalker.walkerLoop@Promise-backend.js:812:7 < this.PromiseWalker.scheduleWalkerLoop/<@Promise-backend.js:746:1 < BG__finalUIStartup@nsBrowserGlue.js:770:1 < BG_observe@nsBrowserGlue.js:284:9 1465632860289addons.xpi-utilsWARNFailed to save XPI database: Error: Could not create new thread! (resource://gre/modules/PromiseWorker.jsm:173:18) JS Stack trace: this.BasePromiseWorker.prototype._worker@PromiseWorker.jsm:173:18 < postMessage@PromiseWorker.jsm:292:9 < TaskImpl_run@Task.jsm:315:40 < Handler.prototype.process@Promise-backend.js:933:23 < this.PromiseWalker.walkerLoop@Promise-backend.js:812:7 < this.PromiseWalker.scheduleWalkerLoop/<@Promise-backend.js:746:1 < BG__finalUIStartup@nsBrowserGlue.js:770:1 < BG_observe@nsBrowserGlue.js:284:9 1465632860289addons.xpi-utilsWARNFailed to save XPI database: Error: Could not create new thread! (resource://gre/modules/PromiseWorker.jsm:173:18) JS Stack trace: this.BasePromiseWorker.prototype._worker@PromiseWorker.jsm:173:18 < postMessage@PromiseWorker.jsm:292:9 < TaskImpl_run@Task.jsm:315:40 < Handler.prototype.process@Promise-backend.js:933:23 < this.PromiseWalker.walkerLoop@Promise-backend.js:812:7 < this.PromiseWalker.scheduleWalkerLoop/<@Promise-backend.js:746:1 < BG__finalUIStartup@nsBrowserGlue.js:770:1 < BG_observe@nsBrowserGlue.js:284:9 1465632860290addons.xpi-utilsWARNFailed to save XPI database: Error: Could not create new thread! (resource://gre/modules/PromiseWorker.jsm:173:18) JS Stack trace: this.BasePromiseWorker.prototype._worker@PromiseWorker.jsm:173:18 < postMessage@PromiseWorker.jsm:292:9 < TaskImpl_run@Task.jsm:315:40 < Handler.prototype.process@Promise-backend.js:933:23 < this.PromiseWalker.walkerLoop@Promise-backend.js:812:7 < this.PromiseWalker.scheduleWalkerLoop/<@Promise-backend.js:746:1 < BG__finalUIStartup@nsBrowserGlue.js:770:1 < BG_observe@nsBrowserGlue.js:284:9 1465632860358DeferredSave.addons.jsonWARNWrite failed: Error: Could not create new thread! (resource://gre/modules/PromiseWorker.jsm:173:18) JS Stack trace: this.BasePromiseWorker.prototype._worker@PromiseWorker.jsm:173:18 < postMessage@PromiseWorker.jsm:292:9 < TaskImpl_run@Task.jsm:315:40 < Handler.prototype.process@Promise-backend.js:933:23 < this.PromiseWalker.walkerLoop@Promise-backend.js:812:7 < this.PromiseWalker.scheduleWalkerLoop/<@Promise-backend.js:746:1 < BG__finalUIStartup@nsBrowserGlue.js:770:1 < BG_observe@nsBrowserGlue.js:284:9 1465632860359addons.repositoryERRORSaveDBToDisk failed: Error: Could not create new thread! (resource://gre/modules/PromiseWorker.jsm:173:18) JS Stack trace: this.BasePromiseWorker.prototype._worker@PromiseWorker.jsm:173:18 < postMessage@PromiseWorker.jsm:292:9 < TaskImpl_run@Task.jsm:315:40 < Handler.prototype.process@Promise-backend.js:933:23 < this.PromiseWalker.walkerLoop@Promise-backend.js:812:7 < this.PromiseWalker.scheduleWalkerLoop/<@Promise-backend.js:746:1 < BG__finalUIStartup@nsBrowserGlue.js:770:1 < BG_observe@nsBrowserGlue.js:284:9 Segmentation fault [pascal@firefox ~]$
[pascal@localhost ~]$ ulimit -aH core file size (blocks, -c) unlimited data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 579483 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 65536 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) unlimited cpu time (seconds, -t) unlimited max user processes (-u) 579483 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited [pascal@localhost ~]$ 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) 579483 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 32768 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 4096 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited [pascal@localhost ~]$ set /proc/*/task/*/cwd/.; echo $# 306 [pascal@localhost ~]$ prlimit RESOURCE DESCRIPTION SOFT HARD UNITS AS address space limit unlimited unlimited bytes CORE max core file size 0 unlimited blocks CPU CPU time unlimited unlimited seconds DATA max data size unlimited unlimited bytes FSIZE max file size unlimited unlimited blocks LOCKS max number of file locks held unlimited unlimited MEMLOCK max locked-in-memory address space 65536 65536 bytes MSGQUEUE max bytes in POSIX mqueues 819200 819200 bytes NICE max nice prio allowed to raise 0 0 NOFILE max number of open files 32768 65536 NPROC max number of processes 4096 579483 RSS max resident set size unlimited unlimited pages RTPRIO max real-time priority 0 0 RTTIME timeout for real-time tasks unlimited unlimited microsecs SIGPENDING max number of pending signals 579483 579483 STACK max stack size 8388608 unlimited bytes
於 2016 年 6 月 13 日晚上 10:24 編輯添加:
不是圖形使用者界面問題。當我今天嘗試向使用者 su 時,這甚至都行不通。根沒問題。我可以 ls,vi,創建一個新使用者,su 到那個使用者,這個使用者一切正常,我退出並嘗試 su 到有問題的使用者,然後不行。Bash 第一次載入有點像,但即使退出也沒有用。我必須重新連接才能回到根目錄。
[root@firefox ~]# su - pascal Last login: Sat Jun 11 03:08:47 CDT 2016 on pts/1 -bash: fork: retry: No child processes -bash: fork: retry: No child processes -bash: fork: retry: No child processes -bash: fork: retry: No child processes -bash: fork: Resource temporarily unavailable -bash-4.2$ ls -bash: fork: retry: No child processes -bash: fork: retry: No child processes -bash: fork: retry: No child processes -bash: fork: retry: No child processes -bash: fork: Resource temporarily unavailable -bash: fork: retry: No child processes -bash: fork: retry: No child processes -bash: fork: retry: No child processes -bash: fork: retry: No child processes -bash: fork: Resource temporarily unavailable -bash-4.2$ exit logout -bash: fork: retry: No child processes -bash: fork: retry: No child processes -bash: fork: retry: No child processes -bash: fork: retry: No child processes -bash: fork: Resource temporarily unavailable -bash-4.2$
[root@firefox ~]# ls -l / total 126 lrwxrwxrwx. 1 root root 7 Jan 28 23:53 bin -> usr/bin ---- snip ---- drwxr-xr-x. 19 root root 23 May 27 18:03 var [root@firefox ~]# vi /etc/rc.local [root@firefox ~]# useradd test [root@firefox ~]# su - test [test@firefox ~]$ cd [test@firefox ~]$ ls -l total 0 [test@firefox ~]$ ls -l / total 126 lrwxrwxrwx. 1 root root 7 Jan 28 23:53 bin -> usr/bin ---- snip ---- drwxr-xr-x. 19 root root 23 May 27 18:03 var [test@firefox ~]$ vi /etc/rc.local [test@firefox ~]$ exit logout [root@firefox ~]# su - pascal Last login: Mon Jun 13 22:12:12 CDT 2016 on pts/1 su: failed to execute /bin/bash: Resource temporarily unavailable [root@firefox ~]#
nproc 是問題所在:
[root@localhost ~]# ps -eLf | grep pascal | wc -l 4068 [root@localhost ~]# cat /etc/security/limits.d/20-nproc.conf # Default limit for number of user's processes to prevent # accidental fork bombs. # See rhbz #432903 for reasoning. * soft nproc 4096 root soft nproc unlimited [root@localhost ~]#
man limits.conf 狀態:
Also, please note that all limit settings are set per login. They are not global, nor are they permanent; existing only for the duration of the session. One exception is the maxlogin option, this one is system wide. But there is a race, concurrent logins at the same time will not always be detected as such but only counted as one.
在我看來,nproc 僅在每次登錄時強制執行,但在全域範圍內計數。因此,使用 nproc 8192 和 5000 個執行緒登錄不會有任何問題,但是使用 nproc 4096 和 50 個執行緒同時登錄相同的 UID 將無法創建更多,因為全域計數 (5050) 高於其 nproc 設置。
[root@localhost ~]# ps -eLf | grep pascal | grep google/chrome | wc -l 3792