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: runtime error: index out of range [-1] #1

Closed
mholt opened this issue Jan 14, 2020 · 6 comments
Closed

panic: runtime error: index out of range [-1] #1

mholt opened this issue Jan 14, 2020 · 6 comments
Labels
bug Something isn't working

Comments

@mholt
Copy link

mholt commented Jan 14, 2020

Running a simple test:

$ cassowary run -u http://localhost:2015 -c 10 -n 100000

Starting Load Test with 100000 requests using 10 concurrent users

 100% |████████████████████████████████████████| [3s:0s]            3.000194405s
panic: runtime error: index out of range [-1]

goroutine 1 [running]:
main.calcMedian(0x0, 0x0, 0x0, 0x17800)
	/Users/rogerwelin/programming/cassowary/stats.go:29 +0xd8
main.(*cassowary).coordinate(0xc00001e700, 0xc00001e700, 0xc00014c120)
	/Users/rogerwelin/programming/cassowary/load.go:203 +0xe04
main.validateRun(0xc0000d4c60, 0x0, 0xc000176060)
	/Users/rogerwelin/programming/cassowary/cli.go:76 +0x35c
github.com/urfave/cli.HandleAction(0x1453980, 0x150e5c0, 0xc0000d4c60, 0xc0000d4c60, 0x0)
	/Users/rogerwelin/go/pkg/mod/github.com/urfave/[email protected]/app.go:523 +0xbe
github.com/urfave/cli.Command.Run(0x14e9f41, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x14f1292, 0xf, 0x0, ...)
	/Users/rogerwelin/go/pkg/mod/github.com/urfave/[email protected]/command.go:174 +0x51c
github.com/urfave/cli.(*App).Run(0xc000130380, 0xc00001e100, 0x8, 0x8, 0x0, 0x0)
	/Users/rogerwelin/go/pkg/mod/github.com/urfave/[email protected]/app.go:276 +0x718
main.runCLI(0xc00001e100, 0x8, 0x8)
	/Users/rogerwelin/programming/cassowary/cli.go:198 +0x946
main.main()
	/Users/rogerwelin/programming/cassowary/main.go:8 +0x45

I'm using this binary on macOS: https://github.com/rogerwelin/cassowary/releases/tag/v0.1.1

@kataras
Copy link
Contributor

kataras commented Jan 14, 2020

Hello @rogerwelin, nice project, keep up this awesome work!

Just to help you, on Windows it works as expected, so the issue @mholt referring is os-specific(?)

image

You have two of the most important open-source go web project authors found your project exactly the same time, you did something special with spreading the news :)

@rogerwelin rogerwelin added the bug Something isn't working label Jan 14, 2020
@rogerwelin
Copy link
Owner

@mholt thanks for reporting the issue. I'm using the same binary on mac but cannot recreate the issue atm. Nonetheless the panic should be handled. I will dig further!

@kataras thanks man, appreciate it! 👍

@mholt
Copy link
Author

mholt commented Jan 14, 2020

Should be an easy fix; it seems that calcMedian doesn't account for slices of len 0. https://github.com/rogerwelin/cassowary/blob/v0.1.1/stats.go#L20-L29

@kataras
Copy link
Contributor

kataras commented Jan 14, 2020

You are welcome @rogerwelin, I opened a new feature request too.

@rogerwelin
Copy link
Owner

@mholt you are very much correct. I've released a new version which fixes this bug, https://github.com/rogerwelin/cassowary/releases/tag/v0.2.0. Big fan of caddy btw!

@mholt
Copy link
Author

mholt commented Jan 14, 2020

Thanks! That did the trick.

@mholt mholt closed this as completed Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants