Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

database/sql: fatal error of concurrent map while logging #61887

Closed
abucu opened this issue Aug 9, 2023 · 2 comments
Closed

database/sql: fatal error of concurrent map while logging #61887

abucu opened this issue Aug 9, 2023 · 2 comments

Comments

@abucu
Copy link

abucu commented Aug 9, 2023

What version of Go are you using (go version)?

1.16.9 and 1.21.0

Does this issue reproduce with the latest release?

Assume to be yes...

What operating system and processor architecture are you using (go env)?

go env Output
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/dida/Library/Caches/go-build'
GOENV='/Users/dida/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/dida/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/dida/go'
GOPRIVATE=''
GOROOT='/usr/local/go'
GOSUMDB='off'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.21.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/w9/9v8mf_pd0z1dy6jy7y4n3vrm0000gn/T/go-build1478959190=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

logging sql.DB directly.. as:

https://go.dev/play/p/_85W8oythtk

What did you expect to see?

better to add a 'String()' for sql.DB struct which has a map in it...

What did you see instead?

panics:

fatal error: concurrent map iteration and map write

goroutine 18 [running]:
reflect.mapiternext(0x46db69?)
	/usr/local/go-faketime/src/runtime/map.go:1397 +0x13
reflect.(*MapIter).Next(0xc00010a7e8?)
	/usr/local/go-faketime/src/reflect/value.go:1940 +0x74
internal/fmtsort.Sort({0x484fa0?, 0xc000090000?, 0x0?})
	/usr/local/go-faketime/src/internal/fmtsort/sort.go:62 +0x1d3
fmt.(*pp).printValue(0xc000104000, {0x484fa0?, 0xc000090000?, 0x0?}, 0x76, 0x2)
	/usr/local/go-faketime/src/fmt/print.go:816 +0x988
@seankhliao
Copy link
Member

there are no exported fields, you're not supposed to access it like this.

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Aug 9, 2023
@abucu
Copy link
Author

abucu commented Aug 10, 2023

there are no exported fields, you're not supposed to access it like this.

  1. json.marshal won't access the un-exported, but 'log' or 'fmt' does ACCESS them, somewhat via 'reflect'..

  2. go vet and race tools can not detect this.

any way to make this more "user" friendly?
any blog or conversation before?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants