Closed wangzlei closed 11 months ago
@wangzlei @srprash
hi all, fatal error 2 still occurs in 1.8.2
fatal error: concurrent map iteration and map write
goroutine 3216017 [running]:
reflect.mapiterinit(0x40?, 0x14ae160?, 0x4003537568?)
/usr/local/go/src/runtime/map.go:1392 +0x1c
reflect.(*MapIter).Next(0x13ad9e0?)
/usr/local/go/src/reflect/value.go:1935 +0x60
encoding/json.mapEncoder.encode({0x40035377d8?}, 0x400379a700, {0x13ad9e0?, 0x4001770600?, 0x165acea?}, {0x6?, 0x0?})
/usr/local/go/src/encoding/json/encode.go:744 +0x28c
encoding/json.structEncoder.encode({{{0x40008fa000, 0x19, 0x23}, 0x4000e400c0, 0x4000e400f0}}, 0x400379a700, {0x1628840?, 0x40017704e0?, 0x12c67350000000f?}, {0x5c?, ...})
/usr/local/go/src/encoding/json/encode.go:706 +0x190
encoding/json.ptrEncoder.encode({0x40035379f8?}, 0x400379a700, {0x1614ca0?, 0x40017704e0?, 0x1000003537a38?}, {0x1c?, 0xd4?})
/usr/local/go/src/encoding/json/encode.go:878 +0x1c4
encoding/json.(*encodeState).reflectValue(0x4003537aa8?, {0x1614ca0?, 0x40017704e0?, 0x12d2e0?}, {0xb8?, 0x7a?})
/usr/local/go/src/encoding/json/encode.go:323 +0x70
encoding/json.(*encodeState).marshal(0x4003537b18?, {0x1614ca0?, 0x40017704e0?}, {0xd8?, 0x5e?})
/usr/local/go/src/encoding/json/encode.go:295 +0xb8
encoding/json.Marshal({0x1614ca0, 0x40017704e0})
/usr/local/go/src/encoding/json/encode.go:162 +0x94
github.com/aws/aws-xray-sdk-go/xray.packSegments.func1(0x40017704e0)
/go/pkg/mod/github.com/aws/aws-xray-sdk-go@v1.8.2/xray/default_emitter.go:106 +0x1a4
github.com/aws/aws-xray-sdk-go/xray.packSegments(0x4004535ba0, {0x400373f920, 0x2, 0x2})
/go/pkg/mod/github.com/aws/aws-xray-sdk-go@v1.8.2/xray/default_emitter.go:116 +0xcc
github.com/aws/aws-xray-sdk-go/xray.packSegments(0x4000103860, {0x400373f920, 0x2, 0x2})
/go/pkg/mod/github.com/aws/aws-xray-sdk-go@v1.8.2/xray/default_emitter.go:115 +0xb0
github.com/aws/aws-xray-sdk-go/xray.(*DefaultEmitter).Emit(0x4000a141b0, 0x18a44?)
/go/pkg/mod/github.com/aws/aws-xray-sdk-go@v1.8.2/xray/default_emitter.go:72 +0x9c
github.com/aws/aws-xray-sdk-go/xray.(*Segment).emit(0x4003d90600?)
/go/pkg/mod/github.com/aws/aws-xray-sdk-go@v1.8.2/xray/segment.go:468 +0x84
github.com/aws/aws-xray-sdk-go/xray.(*Segment).flush(0x1cf4f98?)
/go/pkg/mod/github.com/aws/aws-xray-sdk-go@v1.8.2/xray/segment.go:510 +0x224
github.com/aws/aws-xray-sdk-go/xray.(*Segment).send(0x4000103860)
/go/pkg/mod/github.com/aws/aws-xray-sdk-go@v1.8.2/xray/segment.go:490 +0x60
github.com/aws/aws-xray-sdk-go/xray.(*Segment).handleContextDone(0x4000103860)
/go/pkg/mod/github.com/aws/aws-xray-sdk-go@v1.8.2/xray/segment.go:476 +0x54
github.com/aws/aws-xray-sdk-go/xray.BeginSegmentWithSampling.func1()
/go/pkg/mod/github.com/aws/aws-xray-sdk-go@v1.8.2/xray/segment.go:152 +0x40
created by github.com/aws/aws-xray-sdk-go/xray.BeginSegmentWithSampling in goroutine 3030832
/go/pkg/mod/github.com/aws/aws-xray-sdk-go@v1.8.2/xray/segment.go:150 +0xd2c
Issue #, if available:
The potential concurrency risk could lead to Default_Emitter.Emit() Panic during JSON marshaling. We would like to use recover() to prevent X-ray SDK crashes in the user's application before addressing the root cause.
Description of changes:
Adding defer recover() in Default_Emitter.Emit() function.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.