From 9663d0337ee7e53cf2029ae6dfd5d51a434b9b51 Mon Sep 17 00:00:00 2001 From: Garret Kelly <gdk@google.com> Date: Wed, 7 Jun 2017 16:25:36 -0400 Subject: [PATCH] Add a GrpcLibraryInitializer to client_context.cc It's feasible that a program be written/linked such that it only use ClientContext from grpc++, which could end up with the other instances of GrpcLibraryInitializer not ending up in the final binary. Add a GrpcLibraryInitializer to client_context.cc to ensure that the library is initialized. The primary side-effect of the library not being initialized when only using a ClientContext is that the destructor for ClientContext indirectly ends up trying to call through g_core_codegen_interface when destructing its metadata, which is null. --- src/cpp/client/client_context.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index 14cacc8f18..3af8bdc11a 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -24,6 +24,7 @@ #include <grpc/support/log.h> #include <grpc/support/string_util.h> +#include <grpc++/impl/grpc_library.h> #include <grpc++/security/credentials.h> #include <grpc++/server_context.h> #include <grpc++/support/time.h> @@ -38,6 +39,7 @@ class DefaultGlobalClientCallbacks final void Destructor(ClientContext* context) override {} }; +static internal::GrpcLibraryInitializer g_gli_initializer; static DefaultGlobalClientCallbacks g_default_client_callbacks; static ClientContext::GlobalCallbacks* g_client_callbacks = &g_default_client_callbacks; -- GitLab