protocolbuffers/protobuf

Unrecoverable freeze/crash when calling .extend on repeated field with current object

Open

#7.735 geöffnet am 20. Juli 2020

Auf GitHub ansehen
 (0 Kommentare) (0 Reaktionen) (1 zugewiesene Person)C++ (16.128 Forks)batch import
P3customer issuehelp wantedpython

Repository-Metriken

Stars
 (71.223 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 2T 11h) (185 gemergte PRs in 30 T)

Beschreibung

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