On Thu, May 2, 2019 at 10:31 AM XXX ZZZ <emartinez1...@gmail.com> wrote: > > We are having a random panic on our go application that is happening once > every million requests or so, and so far we haven't been able to reproduce it > nor to even grasp what's going on. > > Basically our code goes like: > > type Subid_info struct{ > Affiliate_subid string > Second_subid string > Second_subid_8 string > S2 string > Internal_subid string > Internal_subid_9 string > Internal_subid_12 string > Result string > } > > func (r *Subid_info) Prepare_subid_logic(){ > r.Second_subid_8=fmt.Sprintf("1%07v", r.Second_subid) ----> panic happens > here. > } > > And the trace we get is: > > panic: runtime error: invalid memory address or nil pointer dereference > [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x466b6e] > > goroutine 17091 [running]: > unicode/utf8.RuneCountInString(0x0, 0x5, 0xc048c275a8) > /usr/local/go/src/unicode/utf8/utf8.go:411 +0x2e > fmt.(*fmt).padString(0xc023c17780, 0x0, 0x5) > /usr/local/go/src/fmt/format.go:113 +0x134 > fmt.(*fmt).fmtS(0xc023c17780, 0x0, 0x5) > /usr/local/go/src/fmt/format.go:347 +0x61 > fmt.(*pp).fmtString(0xc023c17740, 0x0, 0x5, 0xc000000076) > /usr/local/go/src/fmt/print.go:448 +0x132 > fmt.(*pp).printArg(0xc023c17740, 0x9978e0, 0xc016a68a30, 0x76) > /usr/local/go/src/fmt/print.go:684 +0x880 > fmt.(*pp).doPrintf(0xc023c17740, 0xa6e22f, 0x5, 0xc048c27818, 0x1, 0x1) > /usr/local/go/src/fmt/print.go:1112 +0x3ff > fmt.Sprintf(0xa6e22f, 0x5, 0xc048c27818, 0x1, 0x1, 0x80, 0xa36200) > /usr/local/go/src/fmt/print.go:214 +0x66 > code/sharedobjects/sources.(*Subid_info).Prepare_subid_logic(0xc019292f80, > 0x2) > > Given that we can't reproduce it, what's the logical way to debug this and > find out what's happening?
The first thing to try is running your program under the race detector. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.