RenderKit / ospray

An Open, Scalable, Portable, Ray Tracing Based Rendering Engine for High-Fidelity Visualization
http://ospray.org
Apache License 2.0
1k stars 182 forks source link

fix an occasional crash with ospinit/ospShutdown cycles #339

Closed demarle closed 3 years ago

demarle commented 5 years ago

the objectfactory's internal cache of creationfunctionpointers gets stale when a library is dlunloaded. This change fixes that by checking if the the library is still valid and if not making a new cache entry for it.

fixes: https://github.com/ospray/ospray/issues/338

demarle commented 5 years ago

This fix is not complete. The check for library exists will pass when ospray has reloaded the same named libray and we will use the stale function from the old version of the library. We need a timestamp or something like that.

demarle commented 5 years ago

The revised version now says the symbol is stale if the symbols library is at a different address. You can see it take effect here (even if the example won't necessarily crash without it).

#include "ospray/ospray.h"
int main(int argc, const char **argv) {
  for (int i = 0; i < 10000; i++) {
    OSPError init_error = ospInit(nullptr, nullptr);
    if (init_error != OSP_NO_ERROR) {
      return init_error;
    }
    ospShutdown();
  }
  return 0;
}
jeffamstutz commented 5 years ago

We how have ospcommon split into its own repository (due to OpenVKL coming soon, which also needs it), so this will be incorporated into that version of the repo. I'll keep this open as a reference and close it when it's merged there.

johguenther commented 3 years ago

Many (all?) crashes with ospinit/ospShutdown have been fixed in v2.7 (and including the library code in rkcommon).