Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building dynamic library with GCC symbol visibility option linked with protobuf static library causes error “File already exists in database” #8797

Closed
tjliupeng opened this issue Jul 7, 2021 · 6 comments
Labels

Comments

@tjliupeng
Copy link

What version of protobuf and what language are you using?
Version: 2.6.1
Language: C++

What operating system (Linux, Windows, ...) and version?
Linux-like (Porting to some embedded board with ARM)

What runtime / compiler are you using (e.g., python version or gcc version)
gcc, g++ 6.5 (supporting cross-compiling for the OS above)

What did you do?

  1. Application APP depends on libapp.so. libapp.so is built with protocol buffer static library libprotobuf.a which enables fPIC. Interface class is defined in libapp.so. APP calls public methods of that interface class.
  2. At first, everything is fine. After that, as we need to shrink the size of app.so to accelerate the loading speed, it is required to build libapp.so with GCC option "-fvisibility=hidden".
  3. To keep APP can still access the public methods of interface class in the libapp.so, I add "__attribute __((visibility("default")))" to the declarations of those public methods. The building succeeded.
  4. But when APP is started, an exception of protocol buffer is thrown and APP is aborted. The error is as follow:

[libprotobuf ERROR XXXX/protobuf/descriptor_database.cc:57] File already exists in database: xxxx.proto
[libprotobuf FATAL XXXX/protobuf/descriptor.cc:1018] CHECK failed: generated_database_->Add(encoded_file_descriptor, size):
terminate called after throwing an instance of 'google::protobuf::FatalException' what(): CHECK failed: generated_database_->Add(encoded_file_descriptor, size): Aborted.

The error is similar the the protobuf issue #863. But my problem is caused by the GCC symbol visibility option.
According to the error, it seems that the generated proto serializer was loaded twice. But only libapp.so includes the proto serializer.

What's the problem?

@elharo elharo added the c++ label Aug 25, 2021
@himanshu-0611
Copy link

Can I work on this?

@deannagarcia
Copy link
Member

Sorry for the long delay. If you are willing to send a PR that would be very helpful!

@cocoza4
Copy link

cocoza4 commented Feb 21, 2023

what's the status of this? I also face this issue.

@deannagarcia
Copy link
Member

Are you still seeing this issue in 4.22.0? If so, can you open a new issue for it?

@frankhuang014
Copy link

frankhuang014 commented Mar 22, 2023

@deannagarcia
I have occurred similar issue in 3.6.1
I build staic library call 'a.a' with hidden on and 'b.so' link with 'a.a'
executable 'c' link with b.so
What the actually diffenece between 3.6.1 and 4.22.0 which may solve the problem?

@deannagarcia
Copy link
Member

There are many differences between 3.6.1 and 4.22.0. Given that 3.6.1 was released 5 years ago it is outside our support window and we do not investigate issues. Please try using a newer version and create a new issue if you still see this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants