未验证 提交 d740f67a 编写于 作者: L Leo Chen 提交者: GitHub

fix segment fault of protobuf (#54511)

上级 3020ad03
...@@ -45,7 +45,15 @@ def get_msg_dict(msg): ...@@ -45,7 +45,15 @@ def get_msg_dict(msg):
res_dict = {} res_dict = {}
fields = msg.DESCRIPTOR.fields fields = msg.DESCRIPTOR.fields
for f in fields: for f in fields:
res_dict[f.name] = getattr(msg, f.name) v = getattr(msg, f.name)
# NOTE(zhiqiu): convert repeated filed to list to
# avoid segment fault when the process exit?
# WHY?
# I guess the type or value of protobuf item is NULL when
# dealloc.
if f.label == google.protobuf.descriptor.FieldDescriptor.LABEL_REPEATED:
v = list(v)
res_dict[f.name] = v
return res_dict return res_dict
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册