-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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
net/http: ServeFile fails to serve files over 4GB on Windows #33193
Comments
@NickTikhonov I could reproduce your problem on current tip. Thank you very much. I did not have enough time to understand where the problem is. Alex |
@alexbrainman I believe the problem could be some sort of uint overflow. The number of bytes downloaded seems close to the total size modulo |
Change https://golang.org/cl/187037 mentions this issue: |
@NickTikhonov I think I found the problem. Can you, please, try https://go-review.googlesource.com/c/go/+/187037 and see if it fixes the problem for you. Thank you. Alex |
@alexbrainman Thank your fixing this. (I implemented sendfile on Windows) |
You did not say, if https://go-review.googlesource.com/c/go/+/187037 fixes your problem. Please confirm. Thank you. Alex |
I'll reopen this issue as @bradfitz raised a comment on the CL https://go-review.googlesource.com/c/go/+/187037 about perhaps trying to send the file in 2GB chunks instead of failing the first time. |
Change https://golang.org/cl/192143 mentions this issue: |
Change https://golang.org/cl/192518 mentions this issue: |
TransmitFile does not allow for number of bytes that can be transmitted to be larger than 2147483646. See https://docs.microsoft.com/en-us/windows/win32/api/mswsock/nf-mswsock-transmitfile for details. So adjust sendFile accordingly. No test added, because this would require creating large file (more than 2GB file). Fixes golang#33193. Change-Id: I82e0cb104d112264e4ea363bb20b6d02ac30b38e Reviewed-on: https://go-review.googlesource.com/c/go/+/187037 Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
TransmitFile does not allow for number of bytes that can be transmitted to be larger than 2147483646. See https://docs.microsoft.com/en-us/windows/win32/api/mswsock/nf-mswsock-transmitfile for details. So adjust sendFile accordingly. No test added, because this would require creating large file (more than 2GB file). Fixes golang#33193. Change-Id: I82e0cb104d112264e4ea363bb20b6d02ac30b38e Reviewed-on: https://go-review.googlesource.com/c/go/+/187037 Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Change https://golang.org/cl/194218 mentions this issue: |
CL 192518 was a minimal simplification to get sendfile on Windows to work with chunked files, but as I had mentioned, I would add even more improvements. This CL improves it by: * If the reader is not an *io.LimitedReader, since the underlying reader is anyways an *os.File, we fallback and stat that file to determine the file size and then also invoke the chunked sendFile on the underlying reader. This issue existed even before the prior CL. * Extracting the chunked TransmitFile logic and moving it directly into internal/poll.SendFile. Thus if the callers of net.sendFile don't use *io.LimitedReader, but have a huge file (>2GiB), we can still invoke the chunked internal/poll.SendFile on it directly. The test case is not included in this patch as it requires creating a 3GiB file, but that if anyone wants to view it, they can find it at https://go-review.googlesource.com/c/go/+/194218/13/src/net/sendfile_windows_test.go Updates #33193. Change-Id: I97a67c712d558c84ced716d8df98b040cd7ed7f7 Reviewed-on: https://go-review.googlesource.com/c/go/+/194218 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Ran the following script. Before that, you can run
to generate a large file.
What did you expect to see?
I expected the download to have finished,
What did you see instead?
Instead, only 18 bytes are downloaded, and the client receives an unexpected EOF
The text was updated successfully, but these errors were encountered: