Skip to content
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

panic when using Docker Cloud's web console to access influxdb container #7354

Closed
tevjef opened this issue Sep 24, 2016 · 8 comments
Closed

Comments

@tevjef
Copy link

tevjef commented Sep 24, 2016

Bug report

System info: Official docker image, 1.0-alpine,
OS: debian 8

Steps to reproduce:

  1. Start an influxdb Docker container from docker cloud onto a machine/node.
  2. Use Docker CLoud's web terminal/console to access container
  3. Use command influx to use influxdb CLI
  4. Type any character

Expected behavior:

Characters are written to the CLI

Actual behavior:

panics with err: integer divide by zero

Additional info:

/ # influx                                                                                                                                                               
Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.                                                             
Connected to http://localhost:8086 version 1.0.0                                                                                                                         
InfluxDB shell version: 1.0.0                                                                                                                                            
> panic: runtime error: integer divide by zero                                                                                                                           
[signal 0x8 code=0x1 addr=0x61c680 pc=0x61c680]                                                                                                                          

goroutine 1 [running]:                                                                                                                                                   
panic(0x782460, 0xc82000a060)                                                                                                                                            
        /usr/local/go/src/runtime/panic.go:481 +0x3e6                                                                                                                    
github.com/peterh/liner.(*State).refreshMultiLine(0xc8200943c0, 0xc82010d3b8, 0x2, 0x2, 0xc82000a1c0, 0x1, 0x2, 0x1, 0x0, 0x0)                                           
        /root/go/src/github.com/peterh/liner/line.go:159 +0xf0                                                                                                           
github.com/peterh/liner.(*State).refresh(0xc8200943c0, 0xc82010d3b8, 0x2, 0x2, 0xc82000a1c0, 0x1, 0x2, 0x1, 0x0, 0x0)                                                    
        /root/go/src/github.com/peterh/liner/line.go:94 +0x8f                                                                                                            
github.com/peterh/liner.(*State).PromptWithSuggestion(0xc8200943c0, 0x7f2f58, 0x2, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0)                                                    
        /root/go/src/github.com/peterh/liner/line.go:822 +0x1e64                                                                                                         
github.com/peterh/liner.(*State).Prompt(0xc8200943c0, 0x7f2f58, 0x2, 0x0, 0x0, 0x0, 0x0)                                                                                 
        /root/go/src/github.com/peterh/liner/line.go:567 +0x6c                                                                                                           
github.com/influxdata/influxdb/cmd/influx/cli.(*CommandLine).mainLoop(0xc820094280, 0x0, 0x0)                                                                            
        /root/go/src/github.com/influxdata/influxdb/cmd/influx/cli/cli.go:195 +0x17e                                                                                     
github.com/influxdata/influxdb/cmd/influx/cli.(*CommandLine).Run(0xc820094280, 0x0, 0x0)                                                                                 
        /root/go/src/github.com/influxdata/influxdb/cmd/influx/cli/cli.go:181 +0x1483                                                                                    
main.main()                                                                                                                                                              
        /root/go/src/github.com/influxdata/influxdb/cmd/influx/main.go:112 +0x964                                                                                        
/ #                                                                                                                                                                      
/ #                                                                                                                                                                      

Going by the stacktrace and the vender info, I can pinpoint the location of crash in the github.com/peterh/liner library: https://github.com/peterh/liner/blob/8975875355a81d612fafb9f5a6037bdcc2d9b073/line.go#L159

@jwilder
Copy link
Contributor

jwilder commented Nov 17, 2016

Not reproducible.

@jwilder jwilder closed this as completed Nov 17, 2016
@ConnorNe
Copy link

@tevjef Did you find a work around for this? I'm encountering the same problem

@Soulou
Copy link

Soulou commented Feb 6, 2017

We're also having the same probleme here, any idea?

@Soulou
Copy link

Soulou commented Feb 7, 2017

The problem seems to come from here: https://github.com/peterh/liner/blob/8975875355a81d612fafb9f5a6037bdcc2d9b073/output.go#L51-L63

func (s *State) getColumns() bool {
	var ws winSize
	ok, _, _ := syscall.Syscall(syscall.SYS_IOCTL, uintptr(syscall.Stdout),
		syscall.TIOCGWINSZ, uintptr(unsafe.Pointer(&ws)))
	if int(ok) < 0 {
		return false
	}
	s.columns = int(ws.col)
	if cursorColumn && s.columns > 1 {
		s.columns--
	}
	return true
}

The ws.col must equals 0, which result in a panic

@Soulou
Copy link

Soulou commented Feb 7, 2017

Easy to reproduce:

[11:22] Scalingo ~/gopath/src/a $ stty cols 0
[11:22] Scalingo ~/gopath/src/a $ stty rows 0
[11:22] Scalingo ~/gopath/src/a $ influx
InfluxDB shell version: 1.2.0
> lpanic: runtime error: integer divide by zero

goroutine 1 [running]:
panic(0x6de060, 0xc42001e090)
	/usr/local/go/src/runtime/panic.go:500 +0x1a1
github.com/peterh/liner.(*State).refreshMultiLine(0xc42013c000, 0xc4200514a8, 0x2, 0x20, 0xc420051428, 0x1, 0x20, 0x1, 0xc42005133c, 0xc4200f606c)
	/root/go/src/github.com/peterh/liner/line.go:159 +0x5e4

@Soulou
Copy link

Soulou commented Feb 7, 2017

We can reproduce what is done by the package with this gist: https://gist.github.com/Soulou/ad9b094d3b9a56c04995405751301e1b

Result by running this in docker:

sudo docker run -v `pwd`:/mnt -it ubuntu:latest /mnt/poc
true
0

We've the 0 which creates the panic

@Soulou
Copy link

Soulou commented Feb 7, 2017

By adding a sleep in the main:

	s := State{}
	fmt.Println(s.getColumns())
	fmt.Println(s.columns)
	time.Sleep(time.Second)
	s = State{}
	fmt.Println(s.getColumns())
	fmt.Println(s.columns)
└> sudo docker run -v `pwd`:/mnt -it scalingo/builder:v24 /mnt/a
true
0
true
80

We can see that the problem comes from the delay in which docker initialize the stty of the container.

@zorro786
Copy link

Just resize the window after logging in your container/pod. And then execute influx cli.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants