AcademySoftwareFoundation / AcademySoftwareFoundation/OpenShadingLanguage
OSL ShadingSystem::Execute() crashes when OptiX feature enabled
- Dominant language
- C++
- Stars
- 2.3k
- Forks
- 414
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 10
Description
### Problem
I'm finding that ShadingSystem::Execute() crashes when enabling the "OptiX" feature in RenderServices::supports(). It appears to be trying to access some NULL pointer somewhere inside OSL.
**Expected behavior:**
I would have thought that regardless of having OptiX support enabled the CPU runtime should still work as the PTX code is an additional attribute that you can query. I can imagine a situation where you would want to render the same shading network on CPU and GPU which currently would require you to create two RenderServices to do so. One with the "OptiX" feature enabled and one with it disabled. Perhaps this is intended? It sounds like a lot of duplicated work to me if so.
**Actual behavior:**
Calling execute() should run the shading system as expected instead of crashing regardless of if the "Optix" feature is enabled.
### Steps to Reproduce
1. Replace the definition of SimpleRenderer::supports() with the following,
`
int
SimpleRenderer::supports (string_view feature) const
{
return (feature == "OptiX") ? true : false;
}
`
2. You will need to provide the lib_bitcode at some point to get past an assertion. This can be done with the following code copied from OptixRaytracer::init_optix_context(),
`
shadingsys->attribute ("lib_bitcode", {OSL::TypeDesc::UINT8, rend_llvm_compiled_ops_size}, rend_llvm_compiled_ops_block);
`
3. Render some scene with testrender (without the --optix flag)
4. The render should crash on ShadingSystem::Execute()
### Versions
* OSL branch/version: 1.11.0 -> master
* OS: windows
* C++ compiler: icc 17.0.2
* LLVM version: 8
* OIIO version: 2.1.0
Contributor guide
Research direction
Reproduce the crash with testrender without --optix after reviewing SimpleRenderer::supports() and the lib_bitcode setup from OptixRaytracer::init_optix_context(). Start at ShadingSystem::Execute() and trace the NULL access when RenderServices::supports() reports OptiX. Done means CPU execution completes without crashing while OptiX support remains enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100