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

msgpack解码异常时,引起panic,rpcx没捕获异常,导致程序退出 #665

Closed
Leadrive opened this issue Dec 15, 2021 · 4 comments

Comments

@Leadrive
Copy link

panic: reflect: reflect.Value.SetString using unaddressable value

goroutine 106 [running]:
reflect.flag.mustBeAssignableSlow(0x98)
	C:/Go/src/reflect/value.go:260 +0x138
reflect.flag.mustBeAssignable(...)
	C:/Go/src/reflect/value.go:247
reflect.Value.SetString(0x10f3ba0, 0xc000392050, 0x98, 0xc000252f98, 0x8)
	C:/Go/src/reflect/value.go:1746 +0x37
github.com/vmihailenco/msgpack/v5.decodeStringValue(0xc000358cf0, 0x10f3ba0, 0xc000392050, 0x98, 0x10f3ba0, 0xc000392050)
	C:/gowork/pkg/mod/github.com/vmihailenco/msgpack/v5@v5.3.4/decode_string.go:67 +0x8b
github.com/vmihailenco/msgpack/v5.(*Decoder).DecodeValue(0xc000358cf0, 0x10f3ba0, 0xc000392050, 0x98, 0xc000392050, 0x98)
	C:/gowork/pkg/mod/github.com/vmihailenco/msgpack/v5@v5.3.4/decode.go:309 +0x8e
github.com/vmihailenco/msgpack/v5.decodeInterfaceValue(0xc000358cf0, 0x11513a0, 0xc000316780, 0x194, 0x11513a0, 0x11)
	C:/gowork/pkg/mod/github.com/vmihailenco/msgpack/v5@v5.3.4/decode_value.go:184 +0x9a
github.com/vmihailenco/msgpack/v5.(*Decoder).DecodeValue(0xc000358cf0, 0x11513a0, 0xc000316780, 0x194, 0x11513a0, 0xc000316780)
	C:/gowork/pkg/mod/github.com/vmihailenco/msgpack/v5@v5.3.4/decode.go:309 +0x8e
github.com/vmihailenco/msgpack/v5.decodeArrayValue(0xc000358cf0, 0x10fd780, 0xc000316780, 0x191, 0x10fd780, 0x17)
	C:/gowork/pkg/mod/github.com/vmihailenco/msgpack/v5@v5.3.4/decode_slice.go:141 +0x134
github.com/vmihailenco/msgpack/v5.(*Decoder).DecodeValue(0xc000358cf0, 0x10fd780, 0xc000316780, 0x191, 0x10fd780, 0xc000316780)
	C:/gowork/pkg/mod/github.com/vmihailenco/msgpack/v5@v5.3.4/decode.go:309 +0x8e
github.com/vmihailenco/msgpack/v5.decodeSliceValue(0xc000358cf0, 0x10d5a00, 0xc0002b3a48, 0x197, 0x1, 0x1)
	C:/gowork/pkg/mod/github.com/vmihailenco/msgpack/v5@v5.3.4/decode_slice.go:109 +0x205
github.com/vmihailenco/msgpack/v5.(*field).DecodeValue(0xc0002b2540, 0xc000358cf0, 0x120f9c0, 0xc0002b3a40, 0x199, 0x0, 0x0)
	C:/gowork/pkg/mod/github.com/vmihailenco/msgpack/v5@v5.3.4/types.go:118 +0x9a
github.com/vmihailenco/msgpack/v5.(*Decoder).decodeStruct(0xc000358cf0, 0x120f9c0, 0xc0002b3a40, 0x199, 0x4, 0xc0001cbac8, 0xa1e0b2)
	C:/gowork/pkg/mod/github.com/vmihailenco/msgpack/v5@v5.3.4/decode_map.go:324 +0x24f
github.com/vmihailenco/msgpack/v5.decodeStructValue(0xc000358cf0, 0x120f9c0, 0xc0002b3a40, 0x199, 0x120f9c0, 0x17)
	C:/gowork/pkg/mod/github.com/vmihailenco/msgpack/v5@v5.3.4/decode_map.go:282 +0x330
github.com/vmihailenco/msgpack/v5.(*Decoder).DecodeValue(0xc000358cf0, 0x120f9c0, 0xc0002b3a40, 0x199, 0x120f9c0, 0xc0002b3a40)
	C:/gowork/pkg/mod/github.com/vmihailenco/msgpack/v5@v5.3.4/decode.go:309 +0x8e
github.com/vmihailenco/msgpack/v5.decodeSliceValue(0xc000358cf0, 0x10d6500, 0xc0000c4418, 0x197, 0x1, 0x1)
	C:/gowork/pkg/mod/github.com/vmihailenco/msgpack/v5@v5.3.4/decode_slice.go:109 +0x205
github.com/vmihailenco/msgpack/v5.(*field).DecodeValue(0xc000231d80, 0xc000358cf0, 0x12ba120, 0xc0000c43c0, 0x199, 0x0, 0x0)
	C:/gowork/pkg/mod/github.com/vmihailenco/msgpack/v5@v5.3.4/types.go:118 +0x9a
github.com/vmihailenco/msgpack/v5.(*Decoder).decodeStruct(0xc000358cf0, 0x12ba120, 0xc0000c43c0, 0x199, 0x11, 0xc0001cbcc8, 0xa1e0b2)
	C:/gowork/pkg/mod/github.com/vmihailenco/msgpack/v5@v5.3.4/decode_map.go:324 +0x24f
github.com/vmihailenco/msgpack/v5.decodeStructValue(0xc000358cf0, 0x12ba120, 0xc0000c43c0, 0x199, 0x12ba120, 0x88)
	C:/gowork/pkg/mod/github.com/vmihailenco/msgpack/v5@v5.3.4/decode_map.go:282 +0x330
github.com/vmihailenco/msgpack/v5.(*Decoder).DecodeValue(0xc000358cf0, 0x12ba120, 0xc0000c43c0, 0x199, 0xc0000c43c0, 0x199)
	C:/gowork/pkg/mod/github.com/vmihailenco/msgpack/v5@v5.3.4/decode.go:309 +0x8e
github.com/vmihailenco/msgpack/v5.(*Decoder).Decode(0xc000358cf0, 0x12d0000, 0xc0000c43c0, 0x402fde, 0xc0001cbe57)
	C:/gowork/pkg/mod/github.com/vmihailenco/msgpack/v5@v5.3.4/decode.go:288 +0x178
github.com/smallnest/rpcx/codec.MsgpackCodec.Decode(0xc00009e5a3, 0x131, 0x131, 0x12d0000, 0xc0000c43c0, 0x3, 0xc0000a5ae0)
	C:/gowork/pkg/mod/github.com/smallnest/rpcx@v1.6.11/codec/codec.go:104 +0xd0
github.com/smallnest/rpcx/client.(*Client).input(0xc000372340)
	C:/gowork/pkg/mod/github.com/smallnest/rpcx@v1.6.11/client/client.go:697 +0x6d3
created by github.com/smallnest/rpcx/client.(*Client).Connect
	C:/gowork/pkg/mod/github.com/smallnest/rpcx@v1.6.11/client/connection.go:74 +0x1ee

在 C:/gowork/pkg/mod/github.com/smallnest/[email protected]/client/connection.go:74

go c.input()

msgpack解码异常,会引起panic,在线程中,没有捕获,会导致整个程序退出
vmihailenco/msgpack#309

@Leadrive
Copy link
Author

在xclient.Call之前,把输出清一下,目前暂时不出现该错误了。
可能没清除,在解码时混一块了。
作者可以跟踪一下这个错误。

@smallnest
Copy link
Owner

需要一个简单例子复现问题。不清楚是rpcx问题还是vmihailenco/msgpack问题

@smallnest
Copy link
Owner

没有更详细的信息,无法确定问题所在,暂时close。
如果有确定的例子可以提供复现,请再打开此issue

@Aoang
Copy link

Aoang commented Apr 25, 2022

是 msgpack 的问题 (!

今天太晚了,就简单说说怎么复现。

func main() {
	type Data struct {
		Data1 *string
		Data2 *string
		Data3 *string
		Data4 *string
		Data5 *string
	}
	xClient := client.XClient{}

	go func() {
		data := &Data{}
		for i := 0; i < 100; i++ {
			xClient.Call(context.Background(), "name", nil, data)
		}
	}()
}

msgpack 编解码 data 时,会报 panic。

对于 msgpack 的细节可见 vmihailenco/msgpack#310

等有时间了,去提个 pr。建议警告一下用户。这个 bug ,由来已久。。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants