You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What version of protobuf and what language are you using?
Version: 5.29.1 with protoc 29.1
Language: Python
What operating system (Linux, Windows, ...) and version?
Macos 14.6.1
What runtime / compiler are you using (e.g., python version or gcc version)
Python 3.12
What did you do?
Steps to reproduce the behavior:
syntax = "proto3";
import "google/protobuf/struct.proto";
package test;
// TestMessage demonstrates Struct handling
message TestMessage {
// Regular fields
string id = 1;
// Struct field that can hold arbitrary JSON-like data
google.protobuf.Struct data = 2;
}
# -*- coding: utf-8 -*-# Generated by the protocol buffer compiler. DO NOT EDIT!# NO CHECKED-IN PROTOBUF GENCODE# source: test.pb# Protobuf Python Version: 5.29.1"""Generated protocol buffer code."""fromgoogle.protobufimportdescriptoras_descriptorfromgoogle.protobufimportdescriptor_poolas_descriptor_poolfromgoogle.protobufimportruntime_versionas_runtime_versionfromgoogle.protobufimportsymbol_databaseas_symbol_databasefromgoogle.protobuf.internalimportbuilderas_builder_runtime_version.ValidateProtobufRuntimeVersion(
_runtime_version.Domain.PUBLIC,
5,
29,
1,
'',
'test.pb'
)
# @@protoc_insertion_point(imports)_sym_db=_symbol_database.Default()
fromgoogle.protobufimportstruct_pb2asgoogle_dot_protobuf_dot_struct__pb2DESCRIPTOR=_descriptor_pool.Default().AddSerializedFile(b'\n\x07test.pb\x12\x04test\x1a\x1cgoogle/protobuf/struct.proto\"@\n\x0bTestMessage\x12\n\n\x02id\x18\x01\x01(\t\x12%\n\x04\x64\x61ta\x18\x02\x01(\x0b\x32\x17.google.protobuf.Structb\x06proto3')
_globals=globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'test.pb_pb2', _globals)
ifnot_descriptor._USE_C_DESCRIPTORS:
DESCRIPTOR._loaded_options=None_globals['_TESTMESSAGE']._serialized_start=47_globals['_TESTMESSAGE']._serialized_end=111# @@protoc_insertion_point(module_scope)
fromtest_message_pb2importTestMessageimportunittestclassTestStructBehavior(unittest.TestCase):
deftest_empty_struct(self):
# This will trigger the segfault in protobuf v5msg=TestMessage(data={})
# Access the struct to trigger the issuetry:
"key"inmsg.dataexceptExceptionase:
print(f"Error accessing empty struct: {e}")
if__name__=='__main__':
unittest.main()
What did you expect to see
No segfault, either a warning or just the same behaviour as if you do not add an empty dict (same as protobuf 4).
deftestEmptyDict(self):
# in operator for empty initialized structmsg=well_known_types_test_pb2.WKTMessage(optional_struct={})
self.assertFalse('key'inmsg.optional_struct)
What version of protobuf and what language are you using?
Version: 5.29.1 with protoc 29.1
Language: Python
What operating system (Linux, Windows, ...) and version?
Macos 14.6.1
What runtime / compiler are you using (e.g., python version or gcc version)
Python 3.12
What did you do?
Steps to reproduce the behavior:
What did you expect to see
No segfault, either a warning or just the same behaviour as if you do not add an empty dict (same as protobuf 4).
What did you see instead?
A segfault in upb
Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).
Anything else we should know about your project / environment
The text was updated successfully, but these errors were encountered: