Skip to content

Segmentation fault in python protobufs when assigning the wrong message type  #12373

@gwenwahl

Description

@gwenwahl

What version of protobuf and what language are you using?
Version: 4.22.1
Language: Python

What operating system (Linux, Windows, ...) and version?
Appears in MacOS as well as Debian based linux, seems to be platform independent

What runtime / compiler are you using (e.g., python version or gcc version)
Python 3.10.5

What did you do?
If you set the value of a protobuf Message field, that is itself a Message field, to the wrong type of message, this will cause a segmentation fault in python.

An example using included well known types:

Installed packages

-> pip list
Package    Version
---------- -------
pip        22.0.4
protobuf   4.22.1
setuptools 58.1.0

-> python
Python 3.10.5 (main, Jun 28 2022, 11:18:23) [Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from google.protobuf import api_pb2
>>> api_pb2.Api(source_context=api_pb2.Mixin())
[1]    61055 segmentation fault  python

What did you expect to see
I would expect to get an illegal argument exception or something, instead of a seg fault.

What did you see instead?
A segmentation fault

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions