protocolbuffers/protobuf

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

Open

#7 735 ouverte le 20 juil. 2020

Voir sur GitHub
 (0 commentaires) (0 réactions) (1 assigné)C++ (16 128 forks)batch import
P3customer issuehelp wantedpython

Métriques du dépôt

Stars
 (71 223 stars)
Métriques de merge PR
 (Merge moyen 2j 11h) (185 PRs mergées en 30 j)

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.

Guide contributeur