You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by hu...@apache.org on 2026/03/27 13:13:02 UTC
(doris) 07/12: [fix](build) fix macOS BE startup crash caused by fd_number overflow
This is an automated email from the ASF dual-hosted git repository.
huajianlan pushed a commit to branch fe_local_shuffle
in repository https://gitbox.apache.org/repos/asf/doris.git
commit 4a875420efdfd662e3ed991aab6f32c96d7873ee
Author: 924060929 <la...@selectdb.com>
AuthorDate: Thu Mar 26 17:21:11 2026 +0800
[fix](build) fix macOS BE startup crash caused by fd_number overflow
On macOS, getrlimit(RLIMIT_NOFILE) can return RLIM_INFINITY (INT64_MAX).
The calculation fd_number / 100 * segment_cache_fd_percentage produces
1844674407370955160, which overflows cast_set<uint32_t> in SegmentCache
constructor, crashing BE on startup. Linux kernels cap this via fs.nr_open
(default 1M), so only macOS is affected.
Fix: cap fd_number on macOS before the segment cache capacity calculation.
---
be/src/runtime/exec_env_init.cpp | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/be/src/runtime/exec_env_init.cpp b/be/src/runtime/exec_env_init.cpp
index 3b46ca53cb5..7f5341bd0ba 100644
--- a/be/src/runtime/exec_env_init.cpp
+++ b/be/src/runtime/exec_env_init.cpp
@@ -602,6 +602,17 @@ Status ExecEnv::init_mem_env() {
} else {
fd_number = static_cast<uint64_t>(l.rlim_cur);
}
+#ifdef __APPLE__
+ // On macOS, rlim_cur can be RLIM_INFINITY (INT64_MAX), which causes
+ // fd_number / 100 * percentage to overflow and crash cast_set<uint32_t>.
+ // Linux kernels cap this via fs.nr_open (default 1M), so only macOS needs this.
+ {
+ constexpr uint64_t max_fd = UINT32_MAX >> 2;
+ if (fd_number > max_fd) {
+ fd_number = max_fd;
+ }
+ }
+#endif
int64_t segment_cache_capacity = 0;
if (config::is_cloud_mode()) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org