Initializing GrpcCodegen as a global static variable is problematic because it is possible for it to get destructed before the last instance of `GrpcLibraryCodegen` gets destructed and leaves the program dealing with a dangling pointer (imagine a scenario where another thread is using gRPC resources and the main thread tries to join it in an object's destructor after main ends and CoreCodegen is destructed.) In fact, Google style guide explicitly forbids non-trivially-destructible global variables of static storage duration for this and other reasons and the solution in this commit is among the recommended workarounds referenced in https://google.github.io/styleguide/cppguide.html#Static_and_Global_Variablespull/17691/head
parent
2ef35fe9db
commit
b12dd1be05
1 changed files with 4 additions and 5 deletions
Loading…
Reference in new issue