The crashes occur when a Viewer (Hydra) tab that has been kept in the background at all times is closed.
Crash #1: Uninitialised members in the ImageLayer class, used for the Monitor Front Buffer feature of the tab.
Crash #2: Uninitialised GLEW function being used from isGLContextCurrent().
Steps to reproduce crash #1:
Set up a layout that contains a Viewer (Hydra) tab in the background.
Restart Katana.
Close Katana (without never displaying the Viewer (Hydra) tab).
Actual behaviour: Katana may potentially crash on shutdown:
#1 0x00007fffc37266a6 in ImageLayer::~ImageLayer() (this=0x60e000292f20) at Apps/Katana/PLUGINS/ViewerPlugins/GenericPlugins/src/layers/ImageLayer.cpp:66#2 0x00007fffc3726799 in ImageLayer::~ImageLayer() (this=0x60e000292f20) at Apps/Katana/PLUGINS/ViewerPlugins/GenericPlugins/src/layers/ImageLayer.cpp:55
Expected behaviour: Everything goes fine.
NOTE: Crash #1 is random. It may appear on some systems reliably, whereas in others it may never happen. However, building Katana with Clang and the AdddressSanitizers would catch the crash reliably.
NOTE: Crash #1 does not require the RfK plug-in being set up.
Steps to reproduce crash #2:
Set up the RfK plug-in in the KATANA_RESOURCES environment variable.
Set up a layout that contains a Viewer (Hydra) tab in the background.
Restart Katana.
Close Katana (without never displaying the Viewer (Hydra) tab).