Max Lvshadowsocks-libev 与 shadowsocks-android 核心维护者,SIP 规范主导者,meow-rs 内核创立者
GitHub·2026.09.12 15:24:32(UTC+8)

madeye:test_event 失败源于 macOS 进程文件描述符上限

madeye 说明 test_event 失败并非事件循环本身缺陷,而是 macOS 默认每进程文件描述符上限:该测试会故意打开 256 个 UDP socket(以超过 Winsock select 的 64 路限制)等资源。完整技术说明见下方原文。

作者原文@madeye

Thanks for the report. This is caused by macOS's default per-process file descriptor limit rather than a bug in the event loop.

test_event deliberately opens 256 UDP sockets (to exceed Winsock's 64-descriptor select() limit) plus a sender socket and the loop's own kqueue descriptor. A stock macOS Terminal session starts with a soft limit of 256 (ulimit -n prints 256), so socket() starts returning -1 near the end of that loop and the unchecked descriptor trips the bind() assertion you saw. Running with a higher limit already makes the test pass on 3.3.6:

ulimit -n 1024
ctest --test-dir build -L 'unit|vendor' --output-on-failure

https://github.com/shadowsocks/shadowsocks-c/pull/3060 fixes this properly: CTest now raises the soft limit to 1024 before launching each unit test, test_event raises its own limit when run directly, and a socket() failure is now reported as such instead of as a bind() failure.