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

math/rand: Intn: panic index out of range #17629

Closed
WanliTian opened this issue Oct 27, 2016 · 4 comments
Closed

math/rand: Intn: panic index out of range #17629

WanliTian opened this issue Oct 27, 2016 · 4 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@WanliTian
Copy link

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.6.2 linux/amd64

What operating system and processor architecture are you using (go env)?

ubuntu 16.04 ts
Intel® Core™ i5-6200U CPU @ 2.30GHz × 4

panic: runtime error: index out of range

goroutine 550875 [running]:
panic(0xb494e0, 0xc82000a130)
        /home/eric/Code/Go/go/src/runtime/panic.go:481 +0x3e6
math/rand.(*rngSource).Int63(0xc820199500, 0x0)
        /home/eric/Code/Go/go/src/math/rand/rng.go:244 +0xc1
math/rand.(*Rand).Int63(0xc820231350, 0x98)
        /home/eric/Code/Go/go/src/math/rand/rand.go:46 +0x39
math/rand.(*Rand).Int31(0xc820231350, 0xc820d291e0)
        /home/eric/Code/Go/go/src/math/rand/rand.go:52 +0x21
math/rand.(*Rand).Int31n(0xc820231350, 0x1, 0x0)
        /home/eric/Code/Go/go/src/math/rand/rand.go:84 +0x8d
math/rand.(*Rand).Intn(0xc820231350, 0x1, 0xc8201daa24)
        /home/eric/Code/Go/go/src/math/rand/rand.go:101 +0x92

@odeke-em
Copy link
Member

@WanliTian would you mind providing a minimal reproduction for this bug?
Otherwise trying to diagnose or debug this issue is very hard.

@dsnet
Copy link
Member

dsnet commented Oct 27, 2016

Can you also build and test your program with the -race flag? This type of error is highly indicative of a race condition.

@dsnet dsnet added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Oct 27, 2016
@WanliTian
Copy link
Author

i find this #3611, and math.Rand is not safe for concurrent use

@mikioh mikioh changed the title rand.Intn:panic index out of range math/rand: Intn: panic index out of range Oct 27, 2016
@davecheney
Copy link
Contributor

This is most likely a data race in your application. Please check for data
races with go build -race.

If that does not help, please upgrade to the supported version of Go,
1.7.3, and if that does not help, please post a runnable code sample that
demonstrates the issue.

Thank you.

On Thu, Oct 27, 2016 at 5:02 PM, WanliTian notifications@github.com wrote:

Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?

go version go1.6.2 linux/amd64
What operating system and processor architecture are you using (go env)?

ubuntu 16.04 ts
Intel® Core™ i5-6200U CPU @ 2.30GHz × 4

panic: runtime error: index out of range

goroutine 550875 [running]:
panic(0xb494e0, 0xc82000a130)
/home/eric/Code/Go/go/src/runtime/panic.go:481 +0x3e6
math/rand.(_rngSource).Int63(0xc820199500, 0x0)
/home/eric/Code/Go/go/src/math/rand/rng.go:244 +0xc1
math/rand.(_Rand).Int63(0xc820231350, 0x98)
/home/eric/Code/Go/go/src/math/rand/rand.go:46 +0x39
math/rand.(_Rand).Int31(0xc820231350, 0xc820d291e0)
/home/eric/Code/Go/go/src/math/rand/rand.go:52 +0x21
math/rand.(_Rand).Int31n(0xc820231350, 0x1, 0x0)
/home/eric/Code/Go/go/src/math/rand/rand.go:84 +0x8d
math/rand.(*Rand).Intn(0xc820231350, 0x1, 0xc8201daa24)
/home/eric/Code/Go/go/src/math/rand/rand.go:101 +0x92


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#17629, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAcAx5-IEn5RetoUY_VaaBRfsnfUd_Kks5q4D6SgaJpZM4Kh-Ss
.

@golang golang locked and limited conversation to collaborators Oct 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants