pquerna / ffjson

faster JSON serialization for Go
Apache License 2.0
2.97k stars 234 forks source link

Panic runtime.error #138

Open semihalev opened 9 years ago

semihalev commented 9 years ago

Hello,

Today i received panic from ffjson.Marshal , I dont know what is problem exactly. Maybe you can see the problem.

The panic log: panic: runtime error: invalid memory address or nil pointer dereference [recovered] panic: runtime error: invalid memory address or nil pointer dereference [signal 0xb code=0x1 addr=0x0 pc=0x4d204a]

goroutine 653691430 [running]: encoding/json.func·002() /usr/local/go/src/encoding/json/encode.go:262 +0x8b encoding/json.(_encodeState).string(0xc20831b8c0, 0x0, 0x3, 0x0, 0x0, 0x0) /usr/local/go/src/encoding/json/encode.go:790 +0x9a encoding/json.stringEncoder(0xc20831b8c0, 0x747fa0, 0xc209934a30, 0x58, 0xc209934a00) /usr/local/go/src/encoding/json/encode.go:548 +0x29f encoding/json.(_encodeState).reflectValue(0xc20831b8c0, 0x747fa0, 0xc209934a30, 0x58) /usr/local/go/src/encoding/json/encode.go:299 +0x72 encoding/json.interfaceEncoder(0xc20831b8c0, 0x743660, 0xc209934b00, 0x54, 0xc209934a00) /usr/local/go/src/encoding/json/encode.go:557 +0xd9 encoding/json.(_mapEncoder).encode(0xc208094070, 0xc20831b8c0, 0x7b3220, 0xc209e2f1d0, 0x15, 0x0) /usr/local/go/src/encoding/json/encode.go:619 +0x33d encoding/json._mapEncoder.(encoding/json.encode)·fm(0xc20831b8c0, 0x7b3220, 0xc209e2f1d0, 0x15, 0xc209e2f100) /usr/local/go/src/encoding/json/encode.go:629 +0x58 encoding/json.(_encodeState).reflectValue(0xc20831b8c0, 0x7b3220, 0xc209e2f1d0, 0x15) /usr/local/go/src/encoding/json/encode.go:299 +0x72 encoding/json.(_encodeState).marshal(0xc20831b8c0, 0x7b3220, 0xc209e2f1d0, 0x0, 0x0) /usr/local/go/src/encoding/json/encode.go:270 +0xca encoding/json.Marshal(0x7b3220, 0xc209e2f1d0, 0x0, 0x0, 0x0, 0x0, 0x0) /usr/local/go/src/encoding/json/encode.go:135 +0x92 github.com/pquerna/ffjson/ffjson.Marshal(0x7b3220, 0xc209e2f1d0, 0x0, 0x0, 0x0, 0x0, 0x0) /root/go/src/github.com/pquerna/ffjson/ffjson/marshal.go:61 +0x33a

semihalev commented 9 years ago

Maybe same issue? https://github.com/ethereum/go-ethereum/issues/451

pquerna commented 9 years ago

@semihalev Can you share the structure this is happening with?

semihalev commented 9 years ago

https://github.com/drborges/json4go/blob/master/client.go#L99 , i used ffjson here.

klauspost commented 9 years ago

We need a complete reproduction case, since we don't have anything to go by. In the sample there is no indication what "body" really is.

It seems like a crash in a the value of a map[string]interface{} you are trying to encode, and the crash happens when decoding the interface part. Unfortunately encoding/json gobbled up the panic trace, so the actual error is hidden.

kidtronnix commented 7 years ago

also getting a panic error. tbh i don't have time to give a full replication of this issue, but I can say that my service was completely stable until I added ffjson.

kidtronnix commented 7 years ago

I know this does not adress the specific issue with this repo, but for folks just wanting a way to efficiently marshal / unmarshal and have things not panic, i found this library to have better performance and not cause panics!

https://github.com/mailru/easyjson