Optix7 crashes in optixDeviceContextCreate

hi all:
we are using Optix7 to bake lightmaps, sometimes optix crashes in optixDeviceContextCreate.

os: windows 10
driver: 441.12
graphics card: GTX2080TI x 2

optixInit is called in main thread to load optix funtion table when program start, then two renderthreads are spawned. Each thread creates one optix context with cudaContext 0 passed into optixDeviceContextCreate. The logics looks like this:

program start:
main thread:
spawn renderthread

for each baking job:
create optix context
destroy optix context

then after several hours, optix crashed in optixDeviceContextCreate. Is it ok to create and destroy optix context upon each baking?

call stack:
ntdll.dll!RtlReportCriticalFailure() Unknown
ntdll.dll!RtlpHeapHandleError() Unknown
ntdll.dll!RtlpHpHeapHandleError() Unknown
ntdll.dll!RtlpLogHeapFailure() Unknown
ntdll.dll!RtlFreeHeap() Unknown
nvfatbinaryLoader.dll!00007ffcdc800228() Unknown

nvfatbinaryLoader.dll!00007ffcdc777517() Unknown
nvfatbinaryLoader.dll!00007ffcdc773efa() Unknown
nvfatbinaryLoader.dll!00007ffcdc773aa2() Unknown
nvfatbinaryLoader.dll!00007ffcdc7747c8() Unknown
nvfatbinaryLoader.dll!00007ffcdc76524b() Unknown
nvfatbinaryLoader.dll!00007ffcdc763686() Unknown
nvfatbinaryLoader.dll!00007ffcdc7308bd() Unknown
nvfatbinaryLoader.dll!00007ffcdc73052b() Unknown
nvfatbinaryLoader.dll!00007ffcdc72f984() Unknown
nvrtum64.dll!00007ffcb0af8b3c() Unknown
nvrtum64.dll!00007ffcb0af8a72() Unknown
nvrtum64.dll!00007ffcb0a8cc39() Unknown
nvrtum64.dll!00007ffcb0a8bff1() Unknown
nvrtum64.dll!00007ffcb0a8f475() Unknown
nvoptix.dll!00007ffccbfae550() Unknown
nvoptix.dll!00007ffccbfb5a1b() Unknown
rendernode.exe!pt::OptixUtils::CreateOptixContext(const std::experimental::filesystem::v1::path & cachePath) Line 33 C++
rendernode.exe!pt::PTRenderer::Init(unsigned int deviceId, std::shared_ptr scene, unsigned int optBits) Line 124 C++
rendernode.exe!RenderDevice::RenderThread_InitRenderer(std::shared_ptrutils::MemStream sceneData) Line 873 C++
rendernode.exe!RenderDevice::RenderThread_DispatchEvent(const std::shared_ptrnet::Packet & packet) Line 141 C++
rendernode.exe!RenderDevice::RenderThread_Run() Line 52 C++

any idea ?

Yes, there is a known multi-threading issue in functions called by optixDeviceContextCreate which will be fixed in upcoming R440 drivers.
Until the you would either need to put the optixDeviceContextCreate in a single thread or put a mutex around it to make sure they are not called in parallel.

ok, I will try adding mutex!
Thank you so much