Re: [go-nuts] big int panic on text conversion

2024-02-14 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2024-02-14 at 12:24 +0100, Jan Mercl wrote: > On Wed, Feb 14, 2024 at 12:14 PM 'Dan Kortschak' via golang-nuts > wrote: > > > Given that this can happen without a race or unsafe modifications > > it > > might be worth filing a issue for. > > I think this is expected. Quoting from the

Re: [go-nuts] big int panic on text conversion

2024-02-14 Thread Jan Mercl
On Wed, Feb 14, 2024 at 12:14 PM 'Dan Kortschak' via golang-nuts wrote: > Given that this can happen without a race or unsafe modifications it > might be worth filing a issue for. I think this is expected. Quoting from the big.Int docs https://pkg.go.dev/math/big#Int To "copy" an Int

Re: [go-nuts] big int panic on text conversion

2024-02-14 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2024-02-14 at 02:07 -0800, Poonai wrote: > Thanks all, > > figured out the issue: > > func main() { >     a := big.NewInt(1) >     b := *a >     c := *a >     c.Sub(, big.NewInt(1)) >     fmt.Println(b.String()) >     fmt.Println(c.String()) >     fmt.Println(a.String()) > } > > >

Re: [go-nuts] big int panic on text conversion

2024-02-14 Thread Poonai
Thanks all, figured out the issue: func main() { a := big.NewInt(1) b := *a c := *a c.Sub(, big.NewInt(1)) fmt.Println(b.String()) fmt.Println(c.String()) fmt.Println(a.String()) } reproducible code. don't know what causing it tho :( On Wednesday, February 14, 2024

Re: [go-nuts] big int panic on text conversion

2024-02-14 Thread 'Brian Candler' via golang-nuts
Have you tried running your entire code under the race detector? https://go.dev/blog/race-detector On Wednesday 14 February 2024 at 06:02:02 UTC Kurtis Rader wrote: > Maybe provide a minimal reproducible example ( > https://stackoverflow.com/help/minimal-reproducible-example)? > > While it is

Re: [go-nuts] big int panic on text conversion

2024-02-13 Thread Kurtis Rader
Maybe provide a minimal reproducible example ( https://stackoverflow.com/help/minimal-reproducible-example)? While it is theoretically possible there is a bug in the `big` package that could result in such panics it is much more likely the bug is in your code. So showing us how you are using the

Re: [go-nuts] big int panic on text conversion

2024-02-13 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2024-02-13 at 21:35 -0800, Poonai wrote: > big int panics during text conversion randomly  > > stack trace: > > panic: runtime error: index out of range [1] with length 1 > > goroutine 2088184 [running]: > math/big.nat.itoa({0xc01db71500, 0x1, 0x199?}, 0x0, 0xa) >        

[go-nuts] big int panic on text conversion

2024-02-13 Thread Poonai
big int panics during text conversion randomly stack trace: panic: runtime error: index out of range [1] with length 1 goroutine 2088184 [running]: math/big.nat.itoa({0xc01db71500, 0x1, 0x199?}, 0x0, 0xa) /usr/local/go/src/math/big/natconv.go:340 +0x3d2 math/big.(*Int).Text(...)