BurntSushi / BurntSushi/same-file

Handle’s std::os::unix::io::IntoRawFd implementation panics on stdin/stdout/stderr

Open
#55 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
124
Forks
26
PR merge metrics
No merged PRs in 30d

Description

This panics:

```rust
std::os::unix::io::IntoRawFd::into_raw_fd(same_file::Handle::stdin().unwrap())
````

The `Option` field is treated carelessly, and so the reassuring “unwrapping won’t panic” comment in the `Drop` implementation is wrong.

Really, `Option` is the wrong tool to use here; it should be `ManuallyDrop` these days (✓ available within the current MSRV).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the Handle implementation and its std::os::unix::io::IntoRawFd and Drop implementations. Read how the Option field is handled for stdin, stdout, and stderr, then verify that replacing the ownership approach with ManuallyDrop prevents the conversion and cleanup paths from panicking while preserving the current MSRV.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.