protocolbuffers / protocolbuffers/protobuf
Unrecoverable freeze/crash when calling .extend on repeated field with current object
@anandolee is already working on this.
Since Oct 22, 2020.
- Dominant language
- C++
- Stars
- 72k
- Forks
- 16.3k
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 140
Description
What version of protobuf and what language are you using?
Version: 3.12
Language: Python
What operating system (Linux, Windows, ...) and version?
MacOS 10.15.6
What runtime / compiler are you using (e.g., python version or gcc version)
Python 3.7.3 (Clang 11.0.3 (clang-1103.0.32.62) on darwin)
protobuf==3.12.2 ('pip install protobuf')
libprotoc 3.12.3 (installed via Homebrew)
What did you do?
Using the following .proto file:
syntax = "proto3";
message Foo {
message Bar {
uint32 dummy = 1;
}
repeated Bar bars = 1;
}
In a script/interpreter, the following code unrecoverably crashes/freezes (I need to kill my terminal):
>>> import foo_pb2
>>> f = foo_pb2.Foo()
>>> bar = foo_pb2.Foo.Bar()
>>> bar.dummy = 123
>>> f.bars.append(bar)
>>> f.bars.extend(f.bars)
--- TERMINAL FROZEN - NEEDS TO BE KILLED ---
The code below works fine (as I would expect):
>>> import foo_pb2
>>> f1 = foo_pb2.Foo()
>>> bar1 = foo_pb2.Foo.Bar()
>>> bar1.dummy = 123
>>> f1.bars.append(bar1)
>>>
>>> f2 = foo_pb2.Foo()
>>> bar2 = foo_pb2.Foo.Bar()
>>> bar2.dummy = 456
>>> f2.bars.append(bar2)
>>>
>>> f1.bars.extend(f2.bars)
>>>
What did you expect to see
An error, a success, an exception, anything other than what happened.
What did you see instead?
I didn't see anything, but the terminal/python interpreter crashes, and there is no recovery.
I ran into this problem while writing unit tests for my application and I mis-typed a variable, which led me to debug all my code, and then narrow down on this error and come up with a reproducible use case.
The second example is what I MEANT to do, but I accidentally did the first example - and that led to a large test/terminate cycle.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.