dreamworksanimation / openmoonray

MoonRay is DreamWorks’ open-source, award-winning, state-of-the-art production MCRT renderer.
https://openmoonray.org/
Apache License 2.0
4.32k stars 254 forks source link

Segmentation fault rendering USD Moana Island #163

Open nicolaspopravka opened 3 months ago

nicolaspopravka commented 3 months ago

Hi there,

Most likely, there is something wrong on my side, but I am getting a segmentation fault through the Hydra render delegate path while trying to render the Moana Island scene.

% export HDMOONRAY_DEBUG_MODE=1
% hd_render -in ./island/usd/island.usda -out /tmp/island.exr
... # lots of errors and warnings
Hydra setup time = 00:01:17.049
Starting render prep...
Segmentation fault (core dumped)

Is this a known issue ?

nicolaspopravka commented 3 months ago

I spent some time investigating the issue, and here's what gdb reports at the time of the crash:

Thread 55 "hd_render" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fd57ffff700 (LWP 6071)]
moonray::geom::internal::VdbVolume::initializePhase1 (this=0x7fcfe71ef090, vdbFilePath=..., file=..., rdlGeometry=..., layer=0x3fb48b0, volumeAssignmentTable=0x28584800, 
    volumeIds=std::vector of length 0, capacity 0, grids=warning: RTTI symbol not found for class 'std::_Sp_counted_ptr<std::vector<std::shared_ptr<openvdb::v8_2::GridBase>, std::allocator<std::shared_ptr<openvdb::v8_2::GridBase> > >*, (__gnu_cxx::_Lock_policy)2>'
warning: RTTI symbol not found for class 'std::_Sp_counted_ptr<std::vector<std::shared_ptr<openvdb::v8_2::GridBase>, std::allocator<std::shared_ptr<openvdb::v8_2::GridBase> > >*, (__gnu_cxx::_Lock_policy)2>'

std::shared_ptr<std::vector<std::shared_ptr<openvdb::v8_2::GridBase>, std::allocator<std::shared_ptr<openvdb::v8_2::GridBase> > >> (use count 1, weak count 0) = {...}, 
    velocityGrid=std::shared_ptr<openvdb::v8_2::Grid<openvdb::v8_2::tree::Tree<openvdb::v8_2::tree::RootNode<openvdb::v8_2::tree::InternalNode<openvdb::v8_2::tree::InternalNode<openvdb::v8_2::tree::LeafNode<openvdb::v8_2::math::Vec3<float>, 3>, 4>, 5> > > >> (empty) = {...}) at openmoonray/moonray/moonray/lib/rendering/geom/prim/VdbVolume.cc:1095
1095        volumeIds = volumeAssignmentTable->getVolumeIds(*it);

It appears that a null pointer is being dereferenced:

(gdb) p it
$3 = {<std::__detail::_Node_iterator_base<int, false>> = {_M_cur = 0x0}, <No data fields>}

Below is the backtrace leading up to this point:

(gdb) where
#0  moonray::geom::internal::VdbVolume::initializePhase1 (this=0x7fcfe71ef090, vdbFilePath=..., file=..., rdlGeometry=..., layer=0x3fb48b0, volumeAssignmentTable=0x28584800, 
    volumeIds=std::vector of length 0, capacity 0, grids=warning: RTTI symbol not found for class 'std::_Sp_counted_ptr<std::vector<std::shared_ptr<openvdb::v8_2::GridBase>, std::allocator<std::shared_ptr<openvdb::v8_2::GridBase> > >*, (__gnu_cxx::_Lock_policy)2>'
warning: RTTI symbol not found for class 'std::_Sp_counted_ptr<std::vector<std::shared_ptr<openvdb::v8_2::GridBase>, std::allocator<std::shared_ptr<openvdb::v8_2::GridBase> > >*, (__gnu_cxx::_Lock_policy)2>'

std::shared_ptr<std::vector<std::shared_ptr<openvdb::v8_2::GridBase>, std::allocator<std::shared_ptr<openvdb::v8_2::GridBase> > >> (use count 1, weak count 0) = {...}, 
    velocityGrid=std::shared_ptr<openvdb::v8_2::Grid<openvdb::v8_2::tree::Tree<openvdb::v8_2::tree::RootNode<openvdb::v8_2::tree::InternalNode<openvdb::v8_2::tree::InternalNode<openvdb::v8_2::tree::LeafNode<openvdb::v8_2::math::Vec3<float>, 3>, 4>, 5> > > >> (empty) = {...}) at openmoonray/moonray/moonray/lib/rendering/geom/prim/VdbVolume.cc:1095
#1  0x00007fd576e571a6 in moonray::geom::internal::VdbVolume::initialize (this=0x7fcfe71ef090, rdlGeometry=..., layer=<optimized out>, volumeAssignmentTable=<optimized out>)
    at openmoonray/moonray/moonray/lib/rendering/geom/prim/VdbVolume.cc:1207
#2  0x00007fd576e46f60 in moonray::geom::internal::VdbVolume::tessellate (this=0x7fcfe71ef090, tessellationParams=...)
    at openmoonray/moonray/moonray/include/moonray/rendering/geom/prim/Primitive.h:257
#3  0x00007fd57c369af7 in moonray::rt::GeometryManager::<lambda(const tbb::blocked_range<long unsigned int>&)>::operator()(const tbb::blocked_range<unsigned long> &) const (
    __closure=0x7fd063763360, r=...) at openmoonray/moonray/moonray/lib/rendering/rt/GeometryManager.cc:1465
#4  0x00007fd57c36a988 in tbb::interface9::internal::start_for<tbb::blocked_range<long unsigned int>, moonray::rt::GeometryManager::tessellate(scene_rdl2::rdl2::Layer*, moonray::geom::InternalPrimitiveList&, const std::vector<moonray::mcrt_common::Frustum>&, const Mat4d&, const moonray::geom::MotionBlurParams&, const scene_rdl2::rdl2::Camera*)::<lambda(const tbb::blocked_range<long unsigned int>&)>, const tbb::auto_partitioner>::run_body (r=..., this=<optimized out>) at /usr/local/include/tbb/parallel_for.h:113
#5  tbb::interface9::internal::dynamic_grainsize_mode<tbb::interface9::internal::adaptive_mode<tbb::interface9::internal::auto_partition_type> >::work_balance<tbb::interface9::internal::start_for<tbb::blocked_range<long unsigned int>, moonray::rt::GeometryManager::tessellate(scene_rdl2::rdl2::Layer*, moonray::geom::InternalPrimitiveList&, const std::vector<moonray::mcrt_common::Frustum>&, const Mat4d&, const moonray::geom::MotionBlurParams&, const scene_rdl2::rdl2::Camera*)::<lambda(const tbb::blocked_range<long unsigned int>&)>, const tbb::auto_partitioner>, tbb::blocked_range<long unsigned int> > (range=..., start=..., this=<optimized out>) at /usr/local/include/tbb/partitioner.h:438
#6  tbb::interface9::internal::partition_type_base<tbb::interface9::internal::auto_partition_type>::execute<tbb::interface9::internal::start_for<tbb::blocked_range<long unsigned int>, moonray::rt::GeometryManager::tessellate(scene_rdl2::rdl2::Layer*, moonray::geom::InternalPrimitiveList&, const std::vector<moonray::mcrt_common::Frustum>&, const Mat4d&, const moonray::geom::MotionBlurParams&, const scene_rdl2::rdl2::Camera*)::<lambda(const tbb::blocked_range<long unsigned int>&)>, const tbb::auto_partitioner>, tbb::blocked_range<long unsigned int> > (range=..., 
    start=..., this=<optimized out>) at /usr/local/include/tbb/partitioner.h:256
#7  tbb::interface9::internal::start_for<tbb::blocked_range<long unsigned int>, moonray::rt::GeometryManager::tessellate(scene_rdl2::rdl2::Layer*, moonray::geom::InternalPrimitiveList&, const std::vector<moonray::mcrt_common::Frustum>&, const Mat4d&, const moonray::geom::MotionBlurParams&, const scene_rdl2::rdl2::Camera*)::<lambda(const tbb::blocked_range<long unsigned int>&)>, const tbb::auto_partitioner>::execute(void) (this=0x7fd063763340) at /usr/local/include/tbb/parallel_for.h:142
#8  0x00007fd5fd878945 in tbb::internal::custom_scheduler<tbb::internal::IntelSchedulerTraits>::process_bypass_loop (this=this@entry=0x7fd5f6057e00, context_guard=..., t=0x7fd063763340, 
    isolation=isolation@entry=0) at ../../src/tbb/scheduler.h:630
#9  0x00007fd5fd878bfb in tbb::internal::custom_scheduler<tbb::internal::IntelSchedulerTraits>::local_wait_for_all (this=0x7fd5f6057e00, parent=..., child=<optimized out>)
    at ../../include/tbb/task.h:1003
#10 0x00007fd5fd8722a7 in tbb::internal::arena::process (this=0x7fd5f5f04600, s=...) at ../../src/tbb/arena.cpp:196
#11 0x00007fd5fd870c70 in tbb::internal::market::process (this=0x7fd5f61d3580, j=...) at ../../src/tbb/market.cpp:667
#12 0x00007fd5fd86d41c in tbb::internal::rml::private_worker::run (this=0x7fd5f5eff500) at ../../src/tbb/private_server.cpp:266
#13 0x00007fd5fd86d619 in tbb::internal::rml::private_worker::thread_routine (arg=<optimized out>) at ../../src/tbb/private_server.cpp:219
#14 0x00007fd5fd35aea5 in start_thread () from /lib64/libpthread.so.0
#15 0x00007fd5f96b5b0d in clone () from /lib64/libc.so.6

This build was made using the openmoonray-1.5.0.0 tag. There's an assertion just before the dereferencing here that appears to have been commented out in this build. If the assertion were active, it likely would have failed and aborted the program, suggesting that something unexpected is happening in the scene.

Do you have any recommendations for successfully rendering this scene, aside from hiding the /island/osOcean/geometry/deepWaterVolume Volume prim (which gets me past the crash, by the way)? Also, is there any potential fix in the works? Thanks!