gin icon indicating copy to clipboard operation
gin copied to clipboard

fatal error: concurrent map read and map write

Open nickdooley2016 opened this issue 1 year ago • 2 comments

Using go 1.18.3 which seems to be the culprit. Any Ideas?

fatal error: concurrent map read and map write

goroutine 35790993 [running]: runtime.throw({0xeca7f7?, 0xc000113000?}) C:/Program Files/Go/src/runtime/panic.go:992 +0x71 fp=0xc028462cc0 sp=0xc028462c90 pc=0x4343f1 runtime.mapaccess1_faststr(0xeafd82?, 0xc0356dc810?, {0xeafd82, 0x5}) C:/Program Files/Go/src/runtime/map_faststr.go:22 +0x3a5 fp=0xc028462d28 sp=0xc028462cc0 pc=0x412aa5 net/textproto.MIMEHeader.Get(0xc0356dc810, {0xeafd82?, 0x100000000?}) C:/Program Files/Go/src/net/textproto/header.go:34 +0x45 fp=0xc028462d58 sp=0xc028462d28 pc=0x689b25 net/http.Header.Get(...) C:/Program Files/Go/src/net/http/header.go:49 golang.org/x/net/http2.(*clientStream).writeRequest(0xc00b4a8600, 0xc03438ed00) C:/Users/work/go/pkg/mod/golang.org/x/[email protected]/http2/transport.go:1254 +0x347 fp=0xc028462f90 sp=0xc028462d58 pc=0xaa7fc7 golang.org/x/net/http2.(*clientStream).doRequest(0xc02ce975c0?, 0x12?) C:/Users/work/go/pkg/mod/golang.org/x/[email protected]/http2/transport.go:1202 +0x1e fp=0xc028462fc0 sp=0xc028462f90 pc=0xaa7c3e golang.org/x/net/http2.(*ClientConn).RoundTrip.func3() C:/Users/work/go/pkg/mod/golang.org/x/[email protected]/http2/transport.go:1131 +0x2a fp=0xc028462fe0 sp=0xc028462fc0 pc=0xaa7bea runtime.goexit() C:/Program Files/Go/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc028462fe8 sp=0xc028462fe0 pc=0x4643c1 created by golang.org/x/net/http2.(*ClientConn).RoundTrip C:/Users/work/go/pkg/mod/golang.org/x/[email protected]/http2/transport.go:1131 +0x30a

nickdooley2016 avatar Aug 07 '22 13:08 nickdooley2016

Could you be so kind to send snippet of your code or example?

Gasoid avatar Aug 09 '22 15:08 Gasoid

Use sync.Map. Visit this link: https://stackoverflow.com/questions/59294816/converting-standard-golang-map-into-a-sync-map-to-avoid-race-condition

Kamandlou avatar Aug 28 '22 19:08 Kamandlou