Skip to content

mixing with optional fields: core dump --experimental_allow_proto3_optional #7463

@dwsutherland

Description

@dwsutherland

Version: v3.12.0-rc-1
Language: Python3.7.5
Operating system: linux-x86_64
(Linux cortex-vbox 5.3.0-51-generic #44-Ubuntu SMP Wed Apr 22 21:09:44 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux)

protoc pre-compile:
https://github.com/protocolbuffers/protobuf/releases/download/v3.12.0-rc1/protoc-3.12.0-rc-1-linux-x86_64.zip

Install:
pip install protobuf==3.12.0-rc1

It appears the new (3.12.0-rc-1) optional fields work if all singular fields in a message are optional:

message PbTest { optional string test_string = 1; optional bool test_bool = 2; optional int32 test_int32 = 3; } 
>>> from cylc.flow.data_messages_pb2 import PbWorkflow, PbTest >>> test1 = PbTest(test_string='foo', test_bool=True, test_int32=1234) >>> test1 test_string: "foo" test_bool: true test_int32: 1234 >>> test2 = PbTest(test_string='', test_bool=False, test_int32=0) >>> test2 test_string: "" test_bool: false test_int32: 0 >>> test1.MergeFrom(test2) >>> test1 test_string: "" test_bool: false test_int32: 0 

But not if mixed with non-optional:

message PbTest { string no_opt_string = 1; optional string test_string = 2; //optional bool test_bool = 2; //optional int32 test_int32 = 3; } 
>>> from cylc.flow.data_messages_pb2 import PbWorkflow, PbTest >>> test1 = PbTest() >>> test1 [libprotobuf FATAL google/protobuf/generated_message_reflection.cc:1015] CHECK failed: (has_bit_index) != (~0u): terminate called after throwing an instance of 'google::protobuf::FatalException' what(): CHECK failed: (has_bit_index) != (~0u): Aborted (core dumped) 

Also doesn't mix with singular message fields, i.e.:

message PbMeta { string title = 1; string description = 2; string URL = 3; repeated string user_defined = 4; } message PbTest { //repeated string no_opt_strings = 1; optional string test_string = 2; Meta meta = 3; //optional bool test_bool = 2; //optional int32 test_int32 = 3; } 

(optional single message fields do work)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions