Skip to content

math/big: zero divide in ProbablyPrime (garbage collection bug?) #4869

@gopherbot

Description

@gopherbot

by huseby@lindenlab.com:

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. Run this on linux_i386: http://play.golang.org/p/05udxnXbLH
2. Wait for it to have a divide by zero error (only happens very rarely)

What is the expected output?
The rsa.GenerateKey() shouldn't cause a panic.


What do you see instead?
panic: runtime error: integer divide by zero
[signal 0x8 code=0x1 addr=0x80a6898 pc=0x80a6898]

goroutine 10 [running]:
math/big.divWW(0xe49cf0e9, 0x7b5ae8c8, 0x0, 0x188fcac8, 0x17, ...)
    /home/huseby/Projects/go/src/pkg/math/big/arith_386.s:21 +0x8
math/big.nat.divLarge(0x18821870, 0x10, 0x24, 0x188fcaa0, unexpected fault address 0x21,
...0xeef97277
)
    /home/huseby/Projects/go/src/pkg/math/big/nat.go:564 +0x811
math/big.nat.div(0x18821870, 0x10, 0x24, 0x188fcaa0, 0x20, ...)
    /home/huseby/Projects/go/src/pkg/math/big/nat.go:519 +0x26f
math/big.nat.expNNWindowed(0x18821900, 0x20, 0x24, 0x1885f500, 0x10, ...)
    /home/huseby/Projects/go/src/pkg/math/big/nat.go:1358 +0x923
math/big.nat.expNN(0x1885f550, 0x10, 0x14, 0x1885f500, 0x10, ...)
    /home/huseby/Projects/go/src/pkg/math/big/nat.go:1257 +0x3f7
math/big.nat.probablyPrime(0x188ad4b0, 0x10, 0x14, 0x14, 0x6, ...)
    /home/huseby/Projects/go/src/pkg/math/big/nat.go:1442 +0x573
math/big.(*Int).ProbablyPrime(0x1892e0a0, 0x14, 0x35, 0x0)
    /home/huseby/Projects/go/src/pkg/math/big/int.go:726 +0x42
crypto/rand.Prime(0x1873d120, 0x1873d140, 0x200, 0x1892e0a0, 0x0, ...)
    /home/huseby/Projects/go/src/pkg/crypto/rand/util.go:97 +0x337
crypto/rsa.GenerateMultiPrimeKey(0x1873d120, 0x1873d140, 0x2, 0x400, 0x18863480, ...)
    /home/huseby/Projects/go/src/pkg/crypto/rsa/rsa.go:154 +0x192
crypto/rsa.GenerateKey(0x1873d120, 0x1873d140, 0x400, 0x0, 0x0, ...)
    /home/huseby/Projects/go/src/pkg/crypto/rsa/rsa.go:127 +0x51
main.CreateCert(0x1872c540, 0x0)
    /home/huseby/Projects/onion_finder/of.go:35 +0x4f
created by main.main
    /home/huseby/Projects/onion_finder/of.go:121 +0x155


Which compiler are you using (5g, 6g, 8g, gccgo)?

8g

Which operating system are you using?

Ubuntu 12.04 32-bit

Which version are you using?  (run 'go version')

$ go version
go version devel +8d71734a0cb0 Tue Feb 05 09:54:01 2013 -0800 linux/386

Please provide any additional information below.

This is a dual, quad-core Intel(R) Xeon(R) CPU X5492  @ 3.40GHz machine.  I was running
with GOMAXPROCS=10 and --ncpu 9.  It takes many, many iterations to get the panic.

Attachments:

  1. of (2192416 bytes)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions