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

A weird crash during repeated calls to fakeuseragent.Random() #9

Open
ashishb opened this issue Jul 25, 2022 · 2 comments
Open

A weird crash during repeated calls to fakeuseragent.Random() #9

ashishb opened this issue Jul 25, 2022 · 2 comments

Comments

@ashishb
Copy link

ashishb commented Jul 25, 2022

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

goroutine 102 [running]:
math/rand.(*rngSource).Uint64(...)
	/opt/homebrew/Cellar/go/1.18.3/libexec/src/math/rand/rng.go:249
math/rand.(*rngSource).Int63(0xffffffffffffffff?)
	/opt/homebrew/Cellar/go/1.18.3/libexec/src/math/rand/rng.go:234 +0x90
math/rand.(*Rand).Int63(...)
	/opt/homebrew/Cellar/go/1.18.3/libexec/src/math/rand/rand.go:84
math/rand.(*Rand).Int31(...)
	/opt/homebrew/Cellar/go/1.18.3/libexec/src/math/rand/rand.go:98
math/rand.(*Rand).Int31n(0x140003b0060, 0xbb8)
	/opt/homebrew/Cellar/go/1.18.3/libexec/src/math/rand/rand.go:133 +0x50
math/rand.(*Rand).Intn(0x140016a7a18?, 0x14002236be0?)
	/opt/homebrew/Cellar/go/1.18.3/libexec/src/math/rand/rand.go:171 +0x34
github.com/EDDYCJY/fake-useragent/useragent.(*useragent).GetAllRandom(0x140016a7ab8?)
	/Users/ashishb/go/pkg/mod/github.com/!e!d!d!y!c!j!y/[email protected]/useragent/warehouse.go:50 +0x12c
github.com/EDDYCJY/fake-useragent.(*browser).Random(...)
	/Users/ashishb/go/pkg/mod/github.com/!e!d!d!y!c!j!y/[email protected]/browser.go:61
github.com/EDDYCJY/fake-useragent.Random(...)
...
@ashishb
Copy link
Author

ashishb commented Jul 25, 2022

I belive the race condition comes from https://github.com/eddycjy/fake-useragent/blob/master/useragent/warehouse.go#L39 being outside the lock

@fgy58963
Copy link

fgy58963 commented Oct 9, 2022

Same issue occurs at same position.

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

No branches or pull requests

2 participants