protobuf::ShutdownProtobufLibrary()

104 views
Skip to first unread message

softs...@gmail.com

unread,
Dec 3, 2018, 6:16:48 AM12/3/18
to grpc.io
Hello,
we have GRPC interface inside a proprietary Linux dynamic library *.so in C++ which is loaded and unloaded in main process at runtime.
When we unload the library and try to load it again, we get the below error.

[libprotobuf ERROR google/protobuf/descriptor_database.cc:57] File already exists in database: my_interface.proto
[libprotobuf FATAL google/protobuf/descriptor.cc:1314] CHECK failed: generated_database_->Add(encoded_file_descriptor, size):

To clean all internal static objects in protobuf library, we probably need

void protobuf::ShutdownProtobufLibrary()

But the documentation says: "However, it is not safe to use any other part of the protocol buffers library after ShutdownProtobufLibrary() has been called."
So this does not work completely, i.e. allow register and run services again... It looks like a programmer got tired of solving all the involved problems so it ended half-way?
Why "it is not safe", what is missing? Any workaround suggested?

Thank you.

acoz...@google.com

unread,
Dec 5, 2018, 6:57:05 PM12/5/18
to grpc.io
We don't really have good support for dynamically loading and unloading protobuf code. That is something that might work, but we just don't have any tests for it and haven't made an effort to support that. However, you could give it a try and see if it works. I'm not too familiar with dynamic loading, but I would guess that it might be OK to call ShutdownProtobufLibrary() as long as the initialization code runs again before you start calling any protobuf code again.
Reply all
Reply to author
Forward
0 new messages