hermes icon indicating copy to clipboard operation
hermes copied to clipboard

Can't properly initialize and shutdown GLOG

Open ChristopherHogan opened this issue 3 years ago • 0 comments

#273 added proper initialization and finalization of the GLOG library to silence "GLOG not initialized" warnings. However, explicitly shutting down GLOG causes problems with the Hermes VFD.

The Problem

In Hermes::Finalize we call ShutdownGoogleLogging. In the VFD, Hermes::Finalize is called from H5FD__hermes_term, which is a function registered with atexit(3). It appears that atexit(3)-registered functions run after static global objects are destroyed. So, GLOG's static objects are destroyed, then we get to Hermes::Finalize and ShutdownGoogleLogging, where it tries to access those static objects and segfaults.

The Solution

Use IsGoogleLoggingInitialized to see whether or not GLOG needs to be shut down.

The Problem with That

IsGoogleLoggingInitialized is only available in GLOG v.0.5.0.

The Solution

Require GLOG v0.5.0.

The Problem with That

OR-Tools is hardcoded to required GLOG v0.4.0. In newer (> 8.1) versions of OR-Tools they re-implemented their own version of GLOG, so we could update OR-Tools and use GLOG v0.5.0 in Hermes. However, something about the OR-Tools GLOG re-implementation makes it impossible to use in a library that depends on GLOG (i.e., Hermes). Apparently they're waiting for Abseil developers to update to update their flags API (since GFLAGS is now deprecated?).

The Solution

Don't properly init GLOG. Don't properly shutdown GLOG. Live with the warnings. Once this issue is fixed we can update to a newer OR-Tools and GLOG v0.5.0. Alternatively we can replace OR-Tools and avoid all these headaches. See #321.

ChristopherHogan avatar Jan 18 '22 14:01 ChristopherHogan