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

activation: remove unsafe support for fd re-use #276

Merged
merged 2 commits into from
May 11, 2018

Conversation

lucab
Copy link
Contributor

@lucab lucab commented May 7, 2018

Package activation was previously offering an option to leave
environment variables untouched, in order to re-use fd at a future
point.
However, re-using fd is unsafe and results in racing against the GC
due to the way how os.File is implemented. Moreover, the Go runtime
does not (nor plan to) provide a safe interface for proper temporary
borrowing of existing fd.

Thus, this removes the unsetEnv option from all listeners (forcing
to always unset), and only keeps it where ownership can be transferred
back to the caller.

Ref: #250 (comment)
Ref: golang/go#24215

@lucab
Copy link
Contributor Author

lucab commented May 7, 2018

/cc @squeed @vincentbernat for review

This is a followup to #250 (comment). It contains a breaking change for the activation package API.

@lucab lucab requested a review from squeed May 7, 2018 13:03
@lucab
Copy link
Contributor Author

lucab commented May 7, 2018

I also had to bump the ubuntu image we use for tests, as 16.04 comes with an ancient go compiler, and as one of our dependencies (godbus) started using context, and as we don't vendor in here (as this is a library), and as go get does not support checking out a specific tag.

@vincentbernat
Copy link
Contributor

OK for me.

@vincentbernat
Copy link
Contributor

Files() is always called with true. It could also loose its argument.

@lucab
Copy link
Contributor Author

lucab commented May 7, 2018

@vincentbernat yes, we only use it that way. But it is part of the public API and its usage is actually safe, so I plan to keep it as is.

@squeed
Copy link
Contributor

squeed commented May 8, 2018

Looks fine to me! Do you want to add something to the docstring like "you should pass unsetEnv as true unless you know what you're doing"?

lucab added 2 commits May 9, 2018 09:36
Package `activation` was previously offering an option to leave
environment variables untouched, in order to re-use fd at a future
point.
However, re-using fd is unsafe and results in racing against the GC
due to the way how `os.File` is implemented. Moreover, the Go runtime
does not (nor plan to) provide a safe interface for proper temporary
borrowing of existing fd.

Thus, this removes the `unsetEnv` option from all listeners (forcing
to always unset), and only keeps it where ownership can be transferred
back to the caller.
@lucab lucab force-pushed the ups/listeners-always-unset branch from 8a2b307 to 0c07474 Compare May 9, 2018 09:37
@lucab
Copy link
Contributor Author

lucab commented May 9, 2018

@squeed good idea. I added a couple of lines to describe flag rationale and typical usage. Everything else kept untouched, PTAL.
I'd plan to tag v17 right after this.

Copy link
Contributor

@squeed squeed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@lucab lucab merged commit 39ca1b0 into coreos:master May 11, 2018
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.

3 participants