-
-
Notifications
You must be signed in to change notification settings - Fork 172
Closed
Description
While trying to migrate to go-json
, we are seeing a crash in the encoder. The same encoding works fine using encoding/json
and json-iterator/go
.
I don't have the details on what exact struct causes the crash yet, but by the off-chance that you can already see the issue from the stack trace alone, I'm posting it here. Origin of the encoder call here. Struct definition here.
PANIC: runtime error: invalid memory address or nil pointer dereference
/usr/local/go/src/runtime/panic.go:212 (0x43805a)
panicmem: panic(memoryError)
/usr/local/go/src/runtime/signal_unix.go:734 (0x451db2)
sigpanic: panicmem()
/drone/src/vendor/github.com/goccy/go-json/internal/encoder/vm_escaped/util.go:33 (0x6c10eb)
ptrToUint64: func ptrToUint64(p uintptr) uint64 { return **(**uint64)(unsafe.Pointer(&p)) }
/drone/src/vendor/github.com/goccy/go-json/internal/encoder/vm_escaped/vm.go:688 (0x6c10d0)
Run: b = appendInt(b, ptrToUint64(p+code.Offset), code)
/drone/src/vendor/github.com/goccy/go-json/encode.go:281 (0x7475fd)
encodeRunCode: return vm_escaped.Run(ctx, b, codeSet, encoder.Option(opt))
/drone/src/vendor/github.com/goccy/go-json/encode.go:211 (0x746e94)
encode: buf, err := encodeRunCode(ctx, b, codeSet, opt)
/drone/src/vendor/github.com/goccy/go-json/encode.go:95 (0x7467cb)
(*Encoder).encodeWithOption: buf, err = encode(ctx, v, opt)
/drone/src/vendor/github.com/goccy/go-json/encode.go:74 (0x746504)
(*Encoder).EncodeWithOption: err := e.encodeWithOption(ctx, v, optFuncs...)
/drone/src/vendor/github.com/goccy/go-json/encode.go:67 (0x1b1ce84)
(*Encoder).Encode: return e.EncodeWithOption(v)
/drone/src/modules/context/context.go:373 (0x1b1cdea)
(*Context).JSON: if err := json.NewEncoder(ctx.Resp).Encode(content); err != nil {
/drone/src/routers/api/v1/user/gpg_key.go:30 (0x20230d4)
listGPGKeys: ctx.JSON(http.StatusOK, &apiKeys)
Metadata
Metadata
Assignees
Labels
No labels