Error when logging a map using Printf with %v #33800
Labels
FrozenDueToAge
WaitingForInfo
Issue is not actionable because of missing required information, which needs to be provided.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Don't know. Problem is sparse and difficult to replicate.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Unfortunately I haven't been able to reproduce the failure in a smaller piece of code that I can share (working for a private project). Error is sparse and only reproduces ocassionally.
The program has several goroutines running in parallel and communicated with a centralized goroutine that operates as a name service and shares information with each goroutine. Each goroutine registers into the NS, the NS updates the list of registered goroutines, and shares the list after registration with all the goroutines for updating the registry (a copy, not a pointer to it).
The goroutine after receiving the confirmation, uses the log package to show that the updated list is received.
The last line of code failing in my program is:
log.Printf("%v", ag.agentList)
where:
ag is an struct with several fields
agentList is of type map[string]chan<- *Message
and Message is an struct containing several strings.
What did you expect to see?
2019/08/23 14:20:14 map[Agente0:0xc00008a180 Agente1:0xc00008e180 Agente2:0xc00005c060 Agente3:0xc00005c120 Agente4:0xc00008e240 Agente5:0xc000108240 Agente6:0xc000148060 Agente7:0xc00005c360 Agente8:0xc00014a0c0 Agente9:0xc00005c420]
What did you see instead?
map[Agente0:0xc00008a180 Agente1:0xc00008e180 Agente2:0xc00005c060 Agente3:0xc00005c120 Agente4:0xc00008e240 Agente5:0xc000108240 Agente6:0xc000148060 Agente7:0xc00005c360 Agente8:0xc00014a0c0 Agente9:0xc00005c420]
panic: runtime error: index out of range
goroutine 5 [running]:
internal/fmtsort.Sort(0x10b44a0, 0xc000098000, 0x15, 0x15)
/usr/local/opt/go/libexec/src/internal/fmtsort/sort.go:60 +0x34f
fmt.(*pp).printValue(0xc000144000, 0x10b44a0, 0xc000098000, 0x15, 0x76, 0x0)
/usr/local/opt/go/libexec/src/fmt/print.go:759 +0xd20
fmt.(*pp).printArg(0xc000144000, 0x10b44a0, 0xc000098000, 0x76)
/usr/local/opt/go/libexec/src/fmt/print.go:702 +0x2ba
fmt.(*pp).doPrintf(0xc000144000, 0x10d6754, 0x26, 0xc000189e50, 0x2, 0x2)
/usr/local/opt/go/libexec/src/fmt/print.go:1016 +0x158
fmt.Sprintf(0x10d6754, 0x26, 0xc000189e50, 0x2, 0x2, 0x1, 0xc00013c380)
/usr/local/opt/go/libexec/src/fmt/print.go:214 +0x66
log.Printf(0x10d6754, 0x26, 0xc000189e50, 0x2, 0x2)
/usr/local/opt/go/libexec/src/log/log.go:302 +0x53
agents/agent.(*Agent).listen(0xc000136040)
/Users/rcostumero/src/go/src/agents/agent/agent.go:112 +0x912
agents/agent.(*Agent).Register(0xc000136040)
/Users/rcostumero/src/go/src/agents/agent/agent.go:82 +0x33d
created by main.main
/Users/rcostumero/src/go/src/agents/main.go:25 +0x1ab
exit status 2
The text was updated successfully, but these errors were encountered: