Reputation: 1923
I have a proto file written in proto2 syntax. I am compiling this proto file using proto3 compiler. Although it bulids successfully, it shows the following error on runtime. Can someone please help me.
[libprotobuf FATAL google/protobuf/extension_set.cc:102] Multiple extension registrations for type "x.y.z.a", field number 200. terminate called after throwing an instance of 'google::protobuf::FatalException' what(): Multiple extension registrations for type "x.y.z.a", field number 200.
Upvotes: 1
Views: 3034
Reputation: 45191
The error indicates that, somehow, your program has two copies of the definition for this extension. This is probably not protoc's fault, but rather some bug in the way your program is being built.
Here's my theory: You proto file has been separately compiled and linked into two different components/libraries, that are both then being loaded into the same program. One of these components is yours, the other is someone else's that shares the same protocol. The other component was already using protobuf 3.5.1 before, but yours was using 2.3.0. This means you actually had two copies of libprotobuf in your program. Because of this, the two copies of the extension were loaded using different copies of libprotobuf, therefore there was no error. But now you've switched your component to use protobuf 3.5.1, and so now only one copy of libprotobuf is being loaded, and both copies of the proto file are being loaded into that one copy of libprotobuf. So now, you get an error.
To fix this, you need to make sure that your program contains exactly one compiled copy of every proto file. If two components need to share a protocol, then that protocol needs to be factored out into a separate component to be shared.
Upvotes: 1
Reputation: 12176
It sounds like you have a message x.y.z.a
, and you have multiple places where you define an extension with id 200 for it.
So something like this:
package x.y.z;
message a {
extensions 200 to 255;
}
extend a {
optional int32 foo = 200;
}
extend a {
optional int32 bar = 200;
}
So check for such duplicated extensions, which could be defined in multiple files.
Upvotes: 0