Go 1.6: panic in math/rand/rng.go

413 views
Skip to first unread message

Frank Schröder

unread,
Mar 14, 2016, 10:15:26 AM3/14/16
to golang-nuts
Hi gophers,

We are seeing a reasonable number of panics in math/rand/rng.go:243 and I'm wondering if anybody else is experiencing the same issue. Couldn't find an issue on github.

2016/03/14 15:08:20 panic in processor: runtime error: index out of range: goroutine 96194045 [running]:
runtime/debug.Stack(0x0, 0x0, 0x0)
/Users/frschroeder/go1.6/src/runtime/debug/stack.go:24 +0x80
/Users/frschroeder/dev/ecg-icas/icas/src/go/src/git.apache.org/thrift.git/lib/go/thrift/simple_server.go:166 +0x53
panic(0x9b43e0, 0xc82000e020)
/Users/frschroeder/go1.6/src/runtime/panic.go:426 +0x4e9
math/rand.(*rngSource).Int63(0xc820166000, 0x0)
/Users/frschroeder/go1.6/src/math/rand/rng.go:243 +0xcf
math/rand.(*Rand).Int63(0xc8201302d0, 0x10)
/Users/frschroeder/go1.6/src/math/rand/rand.go:46 +0x39
cas/lib/trace.newID(0x0, 0x0)
/Users/frschroeder/dev/ecg-icas/icas/src/go/src/cas/lib/trace/trace.go:268 +0x2f


Thx
Frank

José Mélançon

unread,
Mar 14, 2016, 10:28:40 AM3/14/16
to golang-nuts
Did you run the program under the race detector? I expect someone would've hit this bug too if it wasn't concurrency related, this is common code.

James Bardin

unread,
Mar 14, 2016, 10:29:48 AM3/14/16
to golang-nuts

Are you using the package functions, or a new rand.Rand source? 
Have you checked this with the race detector? The default rand.Rand source isn't safe for concurrent use.
The rand package functions use a singe source protected by a mutex. 


On Monday, March 14, 2016 at 10:15:26 AM UTC-4, Frank Schröder wrote:

Frank Schröder

unread,
Mar 14, 2016, 11:39:06 AM3/14/16
to James Bardin, golang-nuts
Thanks. That was the problem. 

Frank Schröder
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/Km07UwKmasM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ahmy Yulrizka

unread,
Mar 14, 2016, 4:48:27 PM3/14/16
to golang-nuts
Hi

Found out there are couples of issues that mentioned this.

* https://github.com/golang/go/issues/3611
* https://github.com/golang/go/issues/12471

I did not know this before
> Following Go documentation convention, anything not explicitly documented for concurrency safety is not safe for concurrent use.
Reply all
Reply to author
Forward
0 new messages