Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deploy: Don't leak file descriptor passed for local rebases #2211

Merged
merged 1 commit into from
Aug 28, 2020

Conversation

cgwalters
Copy link
Member

Came up in #2210

@cgwalters
Copy link
Member Author

(Only compile tested)

@lucab
Copy link
Contributor

lucab commented Aug 28, 2020

I've just read the fd-stealing internals behind this and I'm somehow amazed. It seems to be using errno for error-signaling, is it ok to just ignore errors or is some logging customary? Other than that, LGTM.

@jlebon
Copy link
Member

jlebon commented Aug 28, 2020

/lgtm

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cgwalters, jlebon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 5ff769f into coreos:master Aug 28, 2020
@jlebon
Copy link
Member

jlebon commented Aug 28, 2020

I've just read the fd-stealing internals behind this and I'm somehow amazed. It seems to be using errno for error-signaling, is it ok to just ignore errors or is some logging customary?

Yeah... we don't do any logging right now. You're right we probably should in general log something in case it helps to debug some higher-level issues (at least in write contexts, if not in read contexts like this one).

@cgwalters
Copy link
Member Author

cgwalters commented Aug 28, 2020

It seems to be using errno for error-signaling

That's how libc works right?

is it ok to just ignore errors or is some logging customary?

Ah well...see, close() is special. In fact, notice Rust today only exposes close() via impl Drop for File {} (i.e. implicitly)...and doesn't by default check errors either:
https://github.com/rust-lang/rust/blob/71f8d0c8f1060bbe74100f29cc6f2da63d697c28/library/std/src/sys/unix/fd.rs#L274

This is...mostly OK as long as you don't have any buffering involved. But IMO it is an evil trap today in Rust how one can create a BufWriter() and not be required to call flush() explicitly and have that happen at drop where you can't check errors.

@cgwalters
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants