From 467ec722581e7ad573491c5662bcd9544eadd2ed Mon Sep 17 00:00:00 2001 From: yvonne Date: Thu, 29 Oct 2026 21:14:59 +0100 Subject: vfs: keep the open-file cache below RLIMIT_NOFILE on Unix The VFS cache allowed up to 8192 open files on Unix, and main() set the soft RLIMIT_NOFILE to exactly 8192. With large loose romfs dumps (e.g. ~205k files) the cache could exhaust every descriptor, so unrelated opens failed with EMFILE and games crashed on the failed loads. Size the cache from the actual soft limit with 512 descriptors spare, as is already done on Windows, and only raise the limit in main() instead of also lowering higher limits down to 8192. Co-Authored-By: Claude Opus 5.5 --- src/yuzu/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/yuzu/main.cpp') diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index e8c93d451f..c7616e0151 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -122,10 +122,10 @@ int main(int argc, char* argv[]) { _setmaxstdio(8192); #endif // __MSVCRT__ #elif defined(__unix__) || defined(__APPLE__) - // Set the max open file limit to 8192, or the hard limit. + // Raise the open file limit to at least 8192, or the hard limit. // Most sane systems should not hit the hard limit here. struct rlimit rl; - if (getrlimit(RLIMIT_NOFILE, &rl) == 0) { + if (getrlimit(RLIMIT_NOFILE, &rl) == 0 && rl.rlim_cur < 8192) { rl.rlim_cur = std::min(8192, rl.rlim_max); setrlimit(RLIMIT_NOFILE, &rl); } -- cgit v1.2.3