aws / aws-xray-sdk-go

AWS X-Ray SDK for the Go programming language.
Apache License 2.0
276 stars 117 forks source link

panic: runtime error: index out of range [2] with length 2 #358

Open hxy1991 opened 2 years ago

hxy1991 commented 2 years ago

Hi @bhautikpip

I ran into an error in aws-xray-sdk-go@v1.6.0 that caused my process to stop.

panic: runtime error: index out of range [2] with length 2 [recovered]
    panic: runtime error: index out of range [2] with length 2

goroutine 8124494 [running]:
encoding/json.(*encodeState).marshal.func1()
    /usr/local/go/src/encoding/json/encode.go:328 +0x84
panic({0xa570e0, 0x4002224588})
    /usr/local/go/src/runtime/panic.go:838 +0x20c
encoding/json.mapEncoder.encode({0x4002146868?}, 0x40028ea380, {0x9940c0?, 0x400178b018?, 0x4002146898?}, {0x6?, 0x0?})
    /usr/local/go/src/encoding/json/encode.go:800 +0x53c
encoding/json.structEncoder.encode({{{0x4000099300?, 0x114190?, 0x40028ea380?}, 0x40005f6bd0?}}, 0x40028ea380, {0xaa81e0?, 0x400178af00?, 0x400178af00?}, {0x98?, 0x69?})
    /usr/local/go/src/encoding/json/encode.go:761 +0x178
encoding/json.ptrEncoder.encode({0x4002146a88?}, 0x40028ea380, {0xa99fe0?, 0x400178af00?, 0x14002146ae8?}, {0x16?, 0x0?})
    /usr/local/go/src/encoding/json/encode.go:945 +0x1f4
encoding/json.(*encodeState).reflectValue(0x4002146b38?, {0xa99fe0?, 0x400178af00?, 0x110664?}, {0xf8?, 0x6b?})
    /usr/local/go/src/encoding/json/encode.go:360 +0x74
encoding/json.(*encodeState).marshal(0x4002146ba8?, {0xa99fe0?, 0x400178af00?}, {0x80?, 0xa3?})
    /usr/local/go/src/encoding/json/encode.go:332 +0x124
encoding/json.Marshal({0xa99fe0, 0x400178af00})
    /usr/local/go/src/encoding/json/encode.go:161 +0x40
github.com/aws/aws-xray-sdk-go/xray.packSegments.func1(0x400178af00)
    /go/pkg/mod/github.com/aws/aws-xray-sdk-go@v1.6.0/xray/default_emitter.go:100 +0x19c
github.com/aws/aws-xray-sdk-go/xray.packSegments(0x400178ac00, {0x0, 0x0, 0x0})
    /go/pkg/mod/github.com/aws/aws-xray-sdk-go@v1.6.0/xray/default_emitter.go:110 +0xcc
github.com/aws/aws-xray-sdk-go/xray.packSegments(0x400178aa80, {0x0, 0x0, 0x0})
    /go/pkg/mod/github.com/aws/aws-xray-sdk-go@v1.6.0/xray/default_emitter.go:109 +0xb0
github.com/aws/aws-xray-sdk-go/xray.(*DefaultEmitter).Emit(0x40000be168, 0x4002549f50?)
    /go/pkg/mod/github.com/aws/aws-xray-sdk-go@v1.6.0/xray/default_emitter.go:66 +0x70
github.com/aws/aws-xray-sdk-go/xray.(*Segment).emit(...)
    /go/pkg/mod/github.com/aws/aws-xray-sdk-go@v1.6.0/xray/segment.go:431
github.com/aws/aws-xray-sdk-go/xray.(*Segment).flush(0x400178aa80)
    /go/pkg/mod/github.com/aws/aws-xray-sdk-go@v1.6.0/xray/segment.go:473 +0x344
github.com/aws/aws-xray-sdk-go/xray.(*Segment).send(0x400178aa80)
    /go/pkg/mod/github.com/aws/aws-xray-sdk-go@v1.6.0/xray/segment.go:453 +0x64
github.com/aws/aws-xray-sdk-go/xray.(*Segment).handleContextDone(0x400178aa80)
    /go/pkg/mod/github.com/aws/aws-xray-sdk-go@v1.6.0/xray/segment.go:439 +0x58
github.com/aws/aws-xray-sdk-go/xray.BeginSegmentWithSampling.func1()
    /go/pkg/mod/github.com/aws/aws-xray-sdk-go@v1.6.0/xray/segment.go:136 +0x44
created by github.com/aws/aws-xray-sdk-go/xray.BeginSegmentWithSampling
    /go/pkg/mod/github.com/aws/aws-xray-sdk-go@v1.6.0/xray/segment.go:134 +0xdd0

What's the problem with this, please? How can I fix it?

Thanks

bhautikpip commented 2 years ago

Thanks for reporting this. Can you share more information on how you were using SDK? Which instrumentation you were using? Is it possible to provide a small repro code for this as well? More information on setup would be useful for debugging.