-
Notifications
You must be signed in to change notification settings - Fork 157
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 readFile
leaking file descriptors in the presence of asynchronous exceptions
#310
Conversation
Will adding But we can do better job closing handle asap, you are right here. Though I don't think the issue is specific to asynchronous exceptions, so your fix (at least for lazy case) is incomplete. Consider the following case: So consider something like (And thank you for raising the issue!) |
I think the biggest smell is in |
@Yuras, I don't think any bracketing can work for the lazy |
@treeowl I checked But I'm not sure I understand why |
I see no benefit to promptly turning the handle semi-closed. Who cares? |
It's a different question :) If nobody cares, then we only need to fix |
I don't think anyone can care. For semi-closed to matter, someone has to have the actual handle. But |
@treeowl Now I think you are misreading my comment... (sorry if it's not the case). It's about promptly closing the handle, not about turning it into semi-closed. |
I agree, that the change to |
@Yuras, everyone wants the handle closed promptly, but I don't think you can actually do that in a meaningful way in the lazy case. Yes, you can deal with an exception that happens before |
@treeowl Yes, that's exactly what I meant: one could handle exceptions between the end of |
Sorry, wasn't trying to insult you or anything, and I definitely did miss
that subtlety. This stuff is all *terribly* subtle.
…On Wed, Dec 23, 2020, 5:58 PM Yuras ***@***.***> wrote:
@treeowl <https://github.com/treeowl> Yes, that's exactly what I meant:
one could handle exceptions between the end of openFile and the end of
hCloseContents (where handle is converted to semi-closed). I already
wrote that I have no idea whether it's important enough to care, and I'm
not trying to convince anyone to actually handle them. I though @prednaz
<https://github.com/prednaz> cared about this case (note that I wrote the
first comment assuming openFile is correct), but looks like he didn't, so
I guess there is no point in further discussion.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#310 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAOOF7JJ7FB6EEDFDNKP5X3SWJY2ZANCNFSM4VHNSOIQ>
.
|
Still, I don't think there's enough time between finalizer creation and
return from hGetContents to be practically significant. We have to give up
on promptness *somewhere*, and return from openFile seems as good a place
as any.
…On Wed, Dec 23, 2020, 6:01 PM David Feuer ***@***.***> wrote:
Sorry, wasn't trying to insult you or anything, and I definitely did miss
that subtlety. This stuff is all *terribly* subtle.
On Wed, Dec 23, 2020, 5:58 PM Yuras ***@***.***> wrote:
> @treeowl <https://github.com/treeowl> Yes, that's exactly what I meant:
> one could handle exceptions between the end of openFile and the end of
> hCloseContents (where handle is converted to semi-closed). I already
> wrote that I have no idea whether it's important enough to care, and I'm
> not trying to convince anyone to actually handle them. I though @prednaz
> <https://github.com/prednaz> cared about this case (note that I wrote
> the first comment assuming openFile is correct), but looks like he
> didn't, so I guess there is no point in further discussion.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#310 (comment)>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAOOF7JJ7FB6EEDFDNKP5X3SWJY2ZANCNFSM4VHNSOIQ>
> .
>
|
Oh, sorry, it's my fault, I didn't mean anything like that. I was just trying to wrap up the conversation. I'm not a native speaker, and I fail to correctly express myself too often. No offense taken. |
readFile
leaks file descriptors in the presence of asynchronous exceptions. I confirmed that with this test. I would have applied the nice fix forData.Text.IO.readFile
toData.Text.Lazy.IO.readFile
too but it does not get along well with lazy IO because the file handle will immediately be closed before reading is done.