--- protobuf-3.0.0-original/src/google/protobuf/stubs/common.cc 2016-09-07 11:26:39.533184708 +0100 +++ protobuf-3.0.0/src/google/protobuf/stubs/common.cc 2016-09-08 12:17:20.951608185 +0100 @@ -412,7 +412,6 @@ GOOGLE_PROTOBUF_DECLARE_ONCE(shutdown_functions_init); void InitShutdownFunctions() { - shutdown_functions = new vector; shutdown_functions_mutex = new Mutex; } @@ -423,6 +422,8 @@ void OnShutdown(void (*func)()) { InitShutdownFunctionsOnce(); MutexLock lock(shutdown_functions_mutex); + if (internal::shutdown_functions == NULL) + shutdown_functions = new vector; shutdown_functions->push_back(func); } @@ -443,8 +444,6 @@ } delete internal::shutdown_functions; internal::shutdown_functions = NULL; - delete internal::shutdown_functions_mutex; - internal::shutdown_functions_mutex = NULL; } #if PROTOBUF_USE_EXCEPTIONS