mitchellh / libxev

libxev is a cross-platform, high-performance event loop that provides abstractions for non-blocking IO, timers, events, and more and works on Linux (io_uring or epoll), macOS (kqueue), and Wasm + WASI. Available as both a Zig and C API.
MIT License
2.16k stars 76 forks source link

[kqueue] More than 256 Kevents per tick causes OOB #111

Closed steeve closed 1 week ago

steeve commented 3 months ago

If there are more than 256 events to unpack per tick, because of the hard-coded 256 Kevents, an out of bounds crash happens at https://github.com/mitchellh/libxev/blob/43c7e4b3308f359e5b758db2d824d7c447f4ed3f/src/backend/kqueue.zig#L427

I'm not sure increasing the limit is worthwhile, I was thinking of just letting the loop run through another tick.

I found the problem using xev.Async.

mitchellh commented 3 months ago

Good catch. I think increasing it is probably fine (just costs more stack space that we probably have available) but we should also make this more robust and spin the loop again if we can't handle all completions in one tick.