Closed StasJ closed 4 years ago
Hey @StasJ , the value returned by ospGetCurrentDevice()
is actually a refcounted object, so when you call ospShutdown()
and quit your program has a dangling reference to the device. Check out the example app's setup for setting the error functions and callbacks for how to do this: https://github.com/ospray/ospray/blob/master/apps/ospExamples/example_common.h#L12-L48 . In short, you'll want to hang onto the handle returned by ospGetCurrentDevice
and then release it when you're done. So here you'd want to do:
ospInit(&argc, argv);
OSPDevice handle = ospGetCurrentDevice();
ospDeviceSetErrorFunc(handle, [](OSPError, const char*){});
ospRelease(handle);
ospShutdown()
Though actually, since the object is refcounted internally I'd expect it to be cleaned up ok in the local rendering case. So the crash may be actually related to https://github.com/ospray/ospray/issues/441 as well, which will have a similar effect of leaving the device dangling by not calling ospShutdown
With ospDeviceRelease(deviceHandle)
the crash is prevented. Or better using cpp-wrappers cpp::Device::current()
instead ospGetCurrentDevice()
, which automatically releases the device.
The following code will crash