Reject negative descriptors in single-descriptor readiness helpers
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- linux, rust
- Domain
- compilers, networking
Research direction
The issue is in std/net/poll.wave, specifically the functions net_wait_readable, net_wait_writable, and net_wait_connected. Start by examining the Linux poll handling in that file. Add validation to reject negative file descriptors (return -9). Ensure infinite timeout does not cause indefinite wait. Write a regression test using the provided reproduction script, and verify that normal behavior and disabled entries in net_poll are preserved.
Written by the indexing model from the issue text.
Description
Problem
On Linux, net_wait_readable, net_wait_writable, and net_wait_connected in std/net/poll.wave return a timeout result for a negative descriptor instead of a bad-descriptor error. Linux poll ignores negative entries. Source inspection therefore also indicates an indefinite-wait risk with an infinite timeout; the executed reproduction below uses a zero timeout.
Reproduction
Save as repro.wave:
import("std::net::poll")::{net_wait_readable};
fun main() -> i32 {
if (net_wait_readable(-1, 0) == -9) { return 0; }
return 1;
}
From the repository root, stage the matching std and run:
audit_home="$(mktemp -d)"
mkdir -p "$audit_home/.wave/lib/wave"
cp -R std "$audit_home/.wave/lib/wave/std"
HOME="$audit_home" target/release/wavec build repro.wave -O0 --run
HOME="$audit_home" target/release/wavec build repro.wave -O2 --run
Tested at 01955d715dda275de993948037091140bb859174 on Fedora Linux 43, x86_64, with LLVM 21.1.8, at both -O0 and -O2.
Expected: the helper returns -9 and the program exits 0. Actual: it returns 0 and the program exits 1, with no output. The other two helpers behave the same way. An invalid positive descriptor (2147483647) correctly returns -9 in all three helpers.
Scope
Validate negative POSIX descriptors at the single-descriptor helper boundary. Preserve the disabled-entry behavior of generic net_poll on POSIX targets. Windows uses Winsock socket handles rather than POSIX descriptors; do not infer its validation or error mapping from this Linux reproduction. Platform error classification in #508 is separate.
Completion criteria
- All three helpers return
-9immediately for negative descriptors on Linux, including with an infinite timeout; bound the regression process with an external timeout. - Add regressions for negative and invalid positive descriptors.
- Preserve normal readable, writable, and timeout behavior, and disabled entries in POSIX
net_poll.
Difficulty: easy.
- Dominant language
- Rust
- Stars
- 53
- Forks
- 16
- Avg merge
- 3h 38m
- Merged PRs (30d)
- 48
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from wavefnd/Wave
-
enhancement good first issue needs testing
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
enhancement good first issue needs testing
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
bug ci good first issue needs testing
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
bug ci good first issue needs testing
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
bug good first issue os compatibility
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
TheLarkInn/aipm#2413 ·
-
documentation
Difficulty 1/5 Under an hour Newbie friendliness 90/100
alexgorbatchev/simple-ptt#15 ·
-
tooling
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
todo:ticket
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
taikoxyz/taiko-mono#22168 · 1 comment ·