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

Error when filtering stats by --tubes #17

Open
cpascu opened this issue Jan 11, 2017 · 1 comment
Open

Error when filtering stats by --tubes #17

cpascu opened this issue Jan 11, 2017 · 1 comment

Comments

@cpascu
Copy link

cpascu commented Jan 11, 2017

Hi!

I'm trying to filter the stats output by a list of tubes and am getting the following error. Initially I was listing several tubes separated by commas but I realised the same error occurs even with just a single tube.

`beanstool stats --host=xxx.xxx.xxx.xxx:11301 --tubes=dispatcher-fast
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x46664f]

goroutine 1 [running]:
github.com/src-d/beanstool/cli.(*StatsCommand).buildLineFromTubeStats(0xc8200126c0, 0x6316d8, 0x7, 0x0, 0x0, 0x0, 0x0)
/Users/mcuadros/workspace/go/src/github.com/src-d/beanstool/cli/stats.go:76 +0x8f
github.com/src-d/beanstool/cli.(*StatsCommand).PrintStats(0xc8200126c0, 0x0, 0x0)
/Users/mcuadros/workspace/go/src/github.com/src-d/beanstool/cli/stats.go:58 +0x1b5
github.com/src-d/beanstool/cli.(*StatsCommand).Execute(0xc8200126c0, 0xc820013170, 0x0, 0x3, 0x0, 0x0)
/Users/mcuadros/workspace/go/src/github.com/src-d/beanstool/cli/stats.go:36 +0x74
github.com/jessevdk/go-flags.(*Parser).ParseArgs(0xc820078190, 0xc82000a1d0, 0x3, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/mcuadros/workspace/go/src/github.com/jessevdk/go-flags/parser.go:301 +0xa16
github.com/jessevdk/go-flags.(*Parser).Parse(0xc820078190, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/mcuadros/workspace/go/src/github.com/jessevdk/go-flags/parser.go:175 +0x9b
main.main()
/Users/mcuadros/workspace/go/src/github.com/src-d/beanstool/beanstool.go:21 +0x6d4`

ramkumar-kr pushed a commit to ramkumar-kr/beanstool that referenced this issue Oct 3, 2018
- Remove printing of Default Tube stats whether Getstats returns data for it or not
- Remove the special condition to continue for default tube
@ramkumar-kr
Copy link

Hi,
I was able to reproduce the issue as well.

Backtrace

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x116d069]

goroutine 1 [running]:
github.com/src-d/beanstool/cli.(*StatsCommand).buildLineFromTubeStats(0xc000080690, 0x11d0e1c, 0x7, 0x0, 0x134c4a0, 0x0, 0xc0000b21e0)
	/Users/ramkumar/go/src/github.com/src-d/beanstool/cli/stats.go:78 +0xd9
github.com/src-d/beanstool/cli.(*StatsCommand).PrintStats(0xc000080690, 0x0, 0x0)
	/Users/ramkumar/go/src/github.com/src-d/beanstool/cli/stats.go:57 +0x277
github.com/src-d/beanstool/cli.(*StatsCommand).Execute(0xc000080690, 0xc000081140, 0x0, 0x3, 0xc000080690, 0x1)
	/Users/ramkumar/go/src/github.com/src-d/beanstool/cli/stats.go:36 +0x62
github.com/jessevdk/go-flags.(*Parser).ParseArgs(0xc0000b0230, 0xc0000880d0, 0x3, 0x3, 0x100d3c8, 0x30, 0x11b2140, 0xc00009e640, 0xc0000c0380)
	/Users/ramkumar/go/src/github.com/jessevdk/go-flags/parser.go:333 +0x80e
github.com/jessevdk/go-flags.(*Parser).Parse(0xc0000b0230, 0x11d0684, 0x4, 0x11d7609, 0x23, 0x0)
	/Users/ramkumar/go/src/github.com/jessevdk/go-flags/parser.go:190 +0x71
main.main()
	/Users/ramkumar/go/src/github.com/src-d/beanstool/beanstool.go:26 +0x43f
exit status 2

I tried to debug this and was able to figure out this issue and a fix.

TheGetStats function returns only the stats of the tubes mentioned when the --tubes argument is passed. However, in line 54 of stats.go, you are trying to print stats for the default tube as well. This results in the nil pointer dereference error.

To fix this, I removed the render statement and the if statement inside the for loop (line 58) and things seem to work fine.

I have created a pull request with the fix.

@ramkumar-kr ramkumar-kr mentioned this issue Oct 3, 2018
ramkumar-kr pushed a commit to ramkumar-kr/beanstool that referenced this issue Oct 3, 2018
- Remove printing of Default Tube stats whether Getstats returns data for it or not
- Remove the special condition to continue for default tube

Signed-off-by: Ramkumar K R <[email protected]>
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

3 participants