Skip to content

Reject negative descriptors in single-descriptor readiness helpers #710

Closed

Description

@LunaStev

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 -9 immediately 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.

Activity

  1. added
    bug
    good first issue
    needs testing
    on Sep 24, 2026
  2. changed the title [-][Bug]: Reject negative descriptors in single-descriptor readiness helpers[/-] [+]Reject negative descriptors in single-descriptor readiness helpers[/+] on Sep 24, 2026
  3. self-assigned this
    on Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

buggood first issueneeds testing

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions