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

log/slog: panic: bad kind: 9 in JSONHandler Handler().WithAttrs(LogValuer{}) #59727

Closed
vogtp opened this issue Apr 20, 2023 · 1 comment
Closed

Comments

@vogtp
Copy link

vogtp commented Apr 20, 2023

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

$ go version
go version go1.20.3 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/vogtp/.cache/go-build"
GOENV="/home/vogtp/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/vogtp/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/vogtp/go/"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/vogtp/sdk/go1.20.3"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/vogtp/sdk/go1.20.3/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/vogtp/go/src/github.com/vogtp/slog-tests/go.mod"
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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1680678466=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Create a new slog with attributes:

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

What did you expect to see?

A "copy" of slog

What did you see instead?

panic: bad kind: 9

goroutine 1 [running]:
golang.org/x/exp/slog.appendJSONValue(0xc00009ae48, {0x4c0ae0?, {0x4c0ae0?, 0x5b59c8?}})
/tmp/gopath3992858384/pkg/mod/golang.org/x/exp@v0.0.0-20230419192730-864b3d6c5c2c/slog/json_handler.go:145 +0x774
golang.org/x/exp/slog.(*handleState).appendValue(0xc00009ae48, {0x4d1da2?, {0x4c0ae0?, 0x5b59c8?}})
/tmp/gopath3992858384/pkg/mod/golang.org/x/exp@v0.0.0-20230419192730-864b3d6c5c2c/slog/handler.go:540 +0x30
golang.org/x/exp/slog.(*handleState).appendAttr(0xc00009ae48, {{0x4d1da2, 0x1}, {0x0, {0x4c0ae0, 0x5b59c8}}})
/tmp/gopath3992858384/pkg/mod/golang.org/x/exp@v0.0.0-20230419192730-864b3d6c5c2c/slog/handler.go:478 +0x6e5
golang.org/x/exp/slog.(*commonHandler).withAttrs(0xc00007a090, {0xc000016120, 0x1, 0x4bb880?})
/tmp/gopath3992858384/pkg/mod/golang.org/x/exp@v0.0.0-20230419192730-864b3d6c5c2c/slog/handler.go:237 +0x4e5
golang.org/x/exp/slog.(*JSONHandler).WithAttrs(0x4c0ae0?, {0xc000016120?, 0xc000094000?, 0x0?})
/tmp/gopath3992858384/pkg/mod/golang.org/x/exp@v0.0.0-20230419192730-864b3d6c5c2c/slog/json_handler.go:54 +0x25
main.main()
/tmp/sandbox1421477762/prog.go:11 +0x15f

@gopherbot
Copy link

Change https://go.dev/cl/486795 mentions this issue: slog: backport changes from stdlib

@golang golang locked and limited conversation to collaborators Apr 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants