Skip to content

Standard file descriptor checks cause abort on startup with strict rlimit #96621

Closed
@QuineDot

Description

@QuineDot

Cause

PR 75295 added polls to the standard file descriptors on startup; if they are closed, it attempts to reopen them to /dev/null. If RLIMIT_NOFILE is too low, the polling (or opening) will cause an abort.

Reported by @edre on URLO; diagnosed by @cuviper.

The rlimit could be checked ahead of time.

Code

I tried this Docker configuration

FROM rust:1.48
RUN rustup target add x86_64-unknown-linux-musl
RUN echo 'fn main(){println!("hi");}' > hi.rs; rustc --target x86_64-unknown-linux-musl -o hi hi.rs
RUN python3 -c 'import resource,subprocess;print(subprocess.run(["/hi"],preexec_fn=lambda: resource.setrlimit(resource.RLIMIT_NOFILE, (0,0))))'

I expected to see this happen: Successful execution

Instead, this happened: Process aborted

Version it worked on

It most recently worked on: Rust 1.47

Versions with regression

Rust 1.48 and forward.

Related issues

@rustbot modify labels: +regression-from-stable-to-stable -regression-untriaged

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-help-wantedCall for participation: Help is requested to fix this issue.P-lowLow priorityT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions