Skip to content

fix(random): use bitwise check for poll revents on Linux - #382

Open
SebTardif wants to merge 2 commits into
mainfrom
fix-f194
Open

fix(random): use bitwise check for poll revents on Linux#382
SebTardif wants to merge 2 commits into
mainfrom
fix-f194

Conversation

@SebTardif

Copy link
Copy Markdown
Owner

Fixes #380

The Linux kernel's random_poll() returns EPOLLIN | EPOLLRDNORM in revents. The strict assert_eq!(fd.revents, libc::POLLIN) panics when POLLRDNORM is also set. Uses a bitwise check instead.

The assert_eq!(fd.revents, libc::POLLIN) panics when the kernel
returns POLLIN | POLLRDNORM in the revents bitmask. The Linux
random_poll function returns EPOLLIN | EPOLLRDNORM, and POLLRDNORM
is a valid companion event. Use a bitwise check instead to verify
POLLIN is set without requiring it to be the only flag.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
Documents that poll() revents is a bitmask and the kernel may set
multiple flags simultaneously (e.g. POLLIN | POLLHUP). Using
assert_eq! instead of bitwise AND fails when extra flags are set.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
@SebTardif SebTardif added bug Something isn't working I-wrong Wrong result or data corruption P-medium Medium impact: affects specific usage patterns A-libs Standard library O-linux Linux-specific labels Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-libs Standard library bug Something isn't working I-wrong Wrong result or data corruption O-linux Linux-specific P-medium Medium impact: affects specific usage patterns

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linux random poll panics when kernel returns POLLIN|POLLRDNORM

1 participant