protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

FileOptions multiple extension registration

Open huta4u opened this issue 6 years ago • 9 comments

I'm trying to utilize file level extension using FileOptions to version proto files.

I created following files:

Version.proto

import "google/protobuf/descriptor.proto";
extend google.protobuf.FileOptions {
  string version = 50001;
}

I have two additional protos that import Version.proto and use option(version) extension:

A.proto

import "Version.proto";
option (version) = "1.0.1";

B.proto

import "Version.proto";
option (version) = "1.0.1";

My setup: Windows 10, C++ VS 2017, protobuf ver 3.4.0. All three protos are compiled by protoc.exe, the output headers & cc files are included into the project. Protobuf.dll linked dynamically.

When I run the application that uses mentioned proto files I get following error just upon startup:

[libprotobuf FATAL google\protobuf\extension_set.cc:102] Multiple extension registrations for type google.protobuf.FileOptions, field number 50001.

Duplicated from https://stackoverflow.com/questions/55627296/fileoptions-extension-in-multiple-protos

huta4u avatar Apr 12 '19 14:04 huta4u

I suspect that the generated code for version.proto is somehow getting linked more than once, which would explain why the problem persists even if you choose a different extension number. Maybe there are multiple DLL's that all include version.proto's generated code?

acozzette avatar Apr 12 '19 15:04 acozzette

@acozzette Good recognition. The setup looks this way: Static lib cotains proto h&cc files. It is linked to DLL and EXEC. The DLL is also linked to EXEC.

huta4u avatar Apr 13 '19 14:04 huta4u

OK, I think the important thing then is just to restructure the app so that the version.proto generated code is only linked once.

acozzette avatar Apr 15 '19 19:04 acozzette

The thing is the proto files are used both in DLL and EXEC. The DLL is shared by other parts of the system also. If I remove static lib containing h&cc files from EXEC or DLL they won't compile.

gmalara avatar Apr 16 '19 08:04 gmalara

Is there a workaround, I am experiencing the same issue when a dynamically linked binary crashes (while the same binary linked statically works). I am hoping that linking libprotobuf dynamically everywhere would fix this, but perhaps someone can confirm?

Dlougach avatar Feb 24 '21 09:02 Dlougach

Related to #7826

fahhem avatar Jul 09 '21 00:07 fahhem

We have the similar issue and load the dynamic library twice which static link to the same protobuf generated library. It works in Linux but crashes in MacOS. It would be great to support in MacOS or we can do something for workaround.

MacOS version is 12.0.1.

tobegit3hub avatar Dec 09 '21 07:12 tobegit3hub

Does someone have a solution for this situation? @fahhem @tobegit3hub

runlilong avatar Mar 16 '22 03:03 runlilong

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

github-actions[bot] avatar May 02 '24 10:05 github-actions[bot]

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.

This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.

github-actions[bot] avatar May 17 '24 10:05 github-actions[bot]