import ("fmt"; "crypto/rsa"; "os")
func main() {
rand, _ := os.Open("/dev/random", os.O_RDONLY, 0)
{
privKey, _ := rsa.GenerateKey(rand, 113)
fmt.Printf("P & Q: %v & %v\n", privKey.P, privKey.Q)
}
{
privKey, _ := rsa.GenerateKey(rand, 114)
fmt.Printf("P & Q: %v & %v\n", privKey.P, privKey.Q)
}
}
How can I go about troubleshooting this? What are people using to profile and debug Go code?
thanks,
-natevw
I think your program is blocking because you are
running the system out of random data. Typically
/dev/urandom is used for things like this.
> How can I go about troubleshooting this?
> What are people using to profile and debug Go code?
You can get a stack trace by doing kill -ABRT pid.
That's about as good as it gets right now.
Russ
That was my initial thought, but while it hangs I was still able to cat from /dev/random. I've changed my code to use /dev/urandom for compatibility, but on OS X /dev/random uses the Yarrow algorithm and is non-blocking as well.
I meant to include in my original post that I'm using GOARCH=amd64, GOOS=darwin and have since tested it with GOARCH=386 as well.
>> How can I go about troubleshooting this?
>> What are people using to profile and debug Go code?
>
> You can get a stack trace by doing kill -ABRT pid.
> That's about as good as it gets right now.
Though my sample size is fairly small, most traces have been within big·divNN. When I tried compiling for GOARCH=386 instead, rsa.GenerateKey for bits > =114 completes in a much more reasonable time. Is there perhaps a performance bug in the big package under amd64? I would have expected large number calculations to be faster with 64- rather than 32-bit instructions available.
thanks,
-natevw
Charlie