-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
runtime: os.File.Close does not interrupt os.File.ReadAt #20110
Comments
In my testing, if I open a pipe in normal blocking mode, read from it in one thread, and then close it from another thread, the read is not interrupted. It simply hangs indefinitely. So as far as I can tell the situation you describe was broken before and it's broken now. I don't see how to fix it. The GNU/Linux man page for
While I think we can probably handle the race condition, that also suggests that closing a file does not interrupt any existing I/O on that file. |
@ianlancetaylor thanks for feedback. What you say about traditional close semantic is also true for sockets. However the issue here was submitted with Go's While it is tempting for me to say that like in #19586 (comment) IO on regular files should be alway really "non-blocking", and thus no cancellation is needed at all, I cannot ignore the fact of FUSE use case and when we already had deadlock where both server and client were tested as part of one process: #19563 (comment) With Close it can be a similar situation: Read request is made; a filesystem there really blocks somehow (NFS / FUSE / ...) but the syscall is handled via bocking way. If Close does not interrupt it - there is simply no way to cancel it. I can imagine interrupting syscall from another P from Close via sending a signal. Offhand this should involve at least some synchronization via fdmu so that the signal is always processed before actual IO operation returns. I'm not sure such complications would be accepted though. |
I don't think the deadlock mentioned above is possible here. The deadlock referenced was due to using I'm going to close this until we have a test case. |
Since CL https://golang.org/cl/41670 os.File.{ReadAt,WriteAt} do not use poller. However os.File.Close logic for interrupting in-flight IO currently works only when poller is used. Quoting #19586 (comment):
Spawning this from #19586 not to forget this problem exists.
The text was updated successfully, but these errors were encountered: