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

Fix fd leak when using direct IOs #1553

Closed
wants to merge 1 commit into from
Closed

Conversation

xiaosuo
Copy link
Contributor

@xiaosuo xiaosuo commented Nov 21, 2016

We should close the fd, before overriding it. This bug was
introduced by f89caa1

We should close the fd, before overriding it. This bug was
introduced by f89caa1
@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

If you are contributing on behalf of someone else (eg your employer): the individual CLA is not sufficient - use https://developers.facebook.com/opensource/cla?type=company instead. Contact cla@fb.com if you have any questions.

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@facebook-github-bot
Copy link
Contributor

@siying has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@siying
Copy link
Contributor

siying commented Nov 21, 2016

I don't understanding why initially we wanted to open the file twice. @kradhakrishnan can you answer that?

@kradhakrishnan
Copy link
Contributor

That is old code nothing got to do with my changes AFAIK. I don't know why the file is tried with two syscalls. Also, the leaks seems generic not really related to O_DIRECT.

@siying
Copy link
Contributor

siying commented Nov 21, 2016

@kradhakrishnan
Copy link
Contributor

I don't remember why I exactly wrote this way. I can understand why I re-open the first call with FILE abstraction since probably there is no way to open O_DIRECT there. The others can be written to avoid not opening twice.

@kradhakrishnan
Copy link
Contributor

This fix looks good to me. I am puzzled how our tsan/asan testing missed these fd leaks . At a later point, the code can be re-written to avoid these double opens. Also, we need to figure why FILE (fopen) is used which is the reason why the double opening started.

@kradhakrishnan
Copy link
Contributor

@xiaosuo Thank you for catching the issue and fixing it.

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.

None yet

5 participants