Skip to content

Fix crash due to hitting FD_SETSIZE limitation of select() (replace with poll()) - #39

Merged
azat merged 1 commit into
masterfrom
fix-crash-due-to-select-limit
May 21, 2026
Merged

azat merged 1 commit into
masterfrom
fix-crash-due-to-select-limit

Conversation

@azat

@azat azat commented May 21, 2026

Copy link
Copy Markdown
Member

When replxx is embedded into a long-running multi-fd process such as clickhouse-server, the PTY input fd and the internal _interrupt pipe fds can be allocated above FD_SETSIZE (1024). FD_SET/FD_ISSET then read/write past the end of the on-stack fd_set, observed as an ASan stack-buffer-overflow inside replxx::Terminal::wait_for_input and as non-deterministic hangs / SIGSEGVs in release builds. poll(2) has no fd-number limit.

…ith poll())

When replxx is embedded into a long-running multi-fd process such as
clickhouse-server, the PTY input fd and the internal _interrupt pipe
fds can be allocated above FD_SETSIZE (1024). FD_SET/FD_ISSET then
read/write past the end of the on-stack `fd_set`, observed as an ASan
stack-buffer-overflow inside replxx::Terminal::wait_for_input and as
non-deterministic hangs / SIGSEGVs in release builds. poll(2) has no
fd-number limit.
@azat
azat force-pushed the fix-crash-due-to-select-limit branch from 0d5ba13 to 1af5fb1 Compare May 21, 2026 16:10
@azat azat changed the title Replace select(2) with poll(2) in Terminal::wait_for_input Fix crash due to hitting FD_SETSIZE limitation of select() (replace with poll()) May 21, 2026
@azat
azat merged commit e26d713 into master May 21, 2026
@azat
azat deleted the fix-crash-due-to-select-limit branch May 22, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant