-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
os: error reading Stdin on windows #13697
Comments
It is syscall.ReadFile returns ERROR_NOT_ENOUGH_MEMORY. I can reproduce it on my both winxp and windows 7. Alex |
I'm also using windows7. Is it related issue of 32bit/64bit? |
My windows xp is 32bit, and my windows 7 is 64bit. Alex |
This is not reproduced on Windows7 32bit. |
I also cannot reproduce on Windows 10 64-bit using the 1.6beta1 build:
|
More information. This fails only if my executable is windows-386 - it fails on both 32bit windows xp and 64bit my windows 7. It works as expected if executable is windows-amd64. Alex |
From https://msdn.microsoft.com/en-us/library/windows/desktop/aa365467(v=vs.85).aspx
I don't see how that's possible, of course, since this is the first read in the entire program. Actually http://microsoft.public.win32.programmer.kernel.narkive.com/A5Q9kG7J/reading-console-input suggests the maximum size you can read from the console is "0x77E8". Can you try this diff:
|
That does not help. You should be able to reproduce this yourself even on windows-amd64 - you just need to build windows-386 exe. Alex |
Unfortunately I've forgotten the password to my windows-amd64 laptop, and
the gomote builders do not have stdin attached to the console. But thanks
for trying.
|
@alexbrainman I tried the patch with But diff --git a/src/os/file_windows.go b/src/os/file_windows.go
index bda495e..ed02962 100644
--- a/src/os/file_windows.go
+++ b/src/os/file_windows.go
@@ -265,8 +265,8 @@ func (f *File) readConsole(b []byte) (n int, err error) {
if len(f.readbuf) == 0 {
numBytes := len(b)
// Windows can't read bytes over max of int16.
- if numBytes > 32767 {
- numBytes = 32767
+ if numBytes > 30000 {
+ numBytes = 30000
}
mbytes := make([]byte, numBytes)
var nmb uint32 When numBytes = 30000, it fixes this. |
I tried this on windows7 64bit. And |
@mattn it does not fixes it fro me on Windows XP windows-386. Alex |
@alexbrainman if the numBytes is more fewer, how it work? |
Which numBytes do you want me to try? If you give me a number, I will try. Alex |
Same result. Still broken. Alex |
I don't know what's going on, but it's certainly not wrong to read fewer bytes, and this does help on some systems, so I am going to send a CL lowering the max. It's not going to matter too much whether we read 32,000 or even 10,000 chars at a time from the console. |
Reading 32,767 is too many on some versions of Windows. The exact upper bound is unclear. For #13697, but may not fix the problem on all systems. Change-Id: I197021ed60cbcd33c91ca6ceed456ec3d5a6c9d6 Reviewed-on: https://go-review.googlesource.com/18433 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Now my program above works on both 386 and amd64. I will let @rsc decide what to do next. Alex |
I'm a little confused but it sounds like no one has a program that fails anymore. Sounds fixed to me! |
I tried to verify if recently closed issue #6303 is fixed, but the program mentioned in the issue is broken now:
Alex
The text was updated successfully, but these errors were encountered: