From d740f67ae7513cc031687148db6e9a5a5a1cd8f4 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Sat, 10 Jun 2023 11:03:43 +0800 Subject: [PATCH] fix segment fault of protobuf (#54511) --- .../distributed/fleet/base/distributed_strategy.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/python/paddle/distributed/fleet/base/distributed_strategy.py b/python/paddle/distributed/fleet/base/distributed_strategy.py index 87d9f77018b..1fbe2f6312f 100755 --- a/python/paddle/distributed/fleet/base/distributed_strategy.py +++ b/python/paddle/distributed/fleet/base/distributed_strategy.py @@ -45,7 +45,15 @@ def get_msg_dict(msg): res_dict = {} fields = msg.DESCRIPTOR.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 -- GitLab