moby: Windows client crashes when run in Intellij terminal

Not really sure if this is an Intellij issue or a Docker client issue, but when you try to run the docker command inside of a terminal in Intellij, the following error is thrown:

C:\Users\James\IdeaProjects\utility-meter-reader>docker
panic: runtime error: makeslice: len out of range

goroutine 1 [running]:
github.com/docker/docker/pkg/term/winconsole.WinConsoleStreams(0x382498, 0xc08200ab40, 0x0, 0x0, 0x0, 0x0)
        /go/src/github.com/docker/docker/pkg/term/winconsole/console_windows.go:252 +0x50f
github.com/docker/docker/pkg/term.StdStreams(0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /go/src/github.com/docker/docker/pkg/term/term_windows.go:34 +0x268
main.main()
        /go/src/github.com/docker/docker/docker/docker.go:34 +0x47

goroutine 5 [runnable]:
os/signal.loop()
        /usr/local/go/src/os/signal/signal_unix.go:19
created by os/signal.init┬À1
        /usr/local/go/src/os/signal/signal_unix.go:27 +0x3c

To reproduce:

  1. Open up Intellij (14.1.1) in Windows (7 SP1)
  2. Bring up the Terminal (Alt+F12)
  3. Type ‘docker’ and hit enter

I am using docker 1.6:

C:\Users\James>docker -v
Docker version 1.6.0, build 4749651

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

So, like some of you I was happily using docker on windows and then randomly this error started to occur - what got weirder was when I discovered it wasn’t random. When my console was maximize the error occured, when it was quarter screen size it did not. So, after a failed attempt at running gdb on windows against the docker exe, i decided to just extract the GetConsoleScreenBufferInfo pieces from console_windows.go and put it in a test go executable and see what it saw. Its a pretty obvious bug once you do that…

The length / capacity of the character buffer slice is specified as:

buffer = make([]CHAR_INFO, screenBufferInfo.MaximumWindowSize.X*screenBufferInfo.MaximumWindowSize.Y)

if we look at the types of X and Y there they are SHORT which is just an alias for int16… so the result of multiplying them is an int16… which is really easy to overflow into a negative, which is exactly what was happening when my console was maximized… and a negative lenght / capacity value is illegal when making a slice.

“test” code - only works on windows and wont’ actually run on playground https://play.golang.org/p/GSRNVYgKzi

I’m not sure this bug still exist on master since things have moved around quite a bit with windows term / console handling. Looks like you’ve switched to using uint16 for the structs, and But It might be nice for people on this issue to see the reason.