Re: [CrystalSpace] #982: terrain2 collider tries to call GetHeight() when height data not loaded

"CrystalSpace" <[email protected]> Tue, 02 Jul 2013 05:28:52 -0000
Newsgroups gmane.comp.graphics.crystalspace.tracker
Message-ID <[email protected]>
#982: terrain2 collider tries to call GetHeight() when height data not loaded
---------------------------+------------------------------------------------
 Reporter:  ralphcampbell  |       Owner:  kickvb  
     Type:  defect         |      Status:  accepted
 Priority:  major          |   Milestone:          
Component:  libs           |     Version:  V2.1    
 Keywords:                 |  
---------------------------+------------------------------------------------

Comment(by ralphcampbell):

 I don't really know the code myself. I agree that only loading data that
 is needed when it is needed is more efficient but I can't really say where
 to place the checks.
 The change I included was just an attempt to get farther along to see what
 other problems might arise. In fact, I still have crashes so my patch
 isn't a complete fix but those crashes appear unrelated to this issue.
 Your patch seems to work as well.
 The original trace was just to show that it was possible to end up
 accessing the array when unloaded.

 Here is the full trace for what it is worth.

 {{{
 Program received signal SIGTRAP, Trace/breakpoint trap.
 0x000000359260eedb in raise (sig=5)
     at ../nptl/sysdeps/unix/sysv/linux/pt-raise.c:41
 41                               sig);
 (gdb) bt
 #0  0x000000359260eedb in raise (sig=5)
     at ../nptl/sysdeps/unix/sysv/linux/pt-raise.c:41
 #1  0x00007ffff771ed7c in CS::Debug::DebugBreak () at
 ./include/cssysdef.h:971
 #2  0x00007ffff771efec in CS::Debug::AssertMessage (expr=
     0x7fffc6648221 "n < count", filename=
     0x7fffc6648208 "./include/csutil/array.h", line=702, msg=0x0)
     at /home/ralphc/src/CS_LATEST/libs/csutil/csassert.cpp:82
 #3  0x00007fffc6622ee0 in csArray<float, csArrayElementHandler<float>,
 CS::Memory::AllocatorMalloc, csArrayCapacityFixedGrow<16> >::Get
 (this=0x7fffd560caf8,
     n=19531) at ./include/csutil/array.h:702
 #4  0x00007fffc6622831 in csArray<float, csArrayElementHandler<float>,
 CS::Memory::AllocatorMalloc, csArrayCapacityFixedGrow<16> >::operator[]
 (this=
     0x7fffd560caf8, n=19531) at ./include/csutil/array.h:739
 #5  0x00007fffc662119f in CS::Plugin::Terrain2::csTerrainCell::GetHeight
 (this=
     0x7fffd560c9e0, x=256, y=75)
     at
 /home/ralphc/src/CS_LATEST/plugins/mesh/terrain/terrain2/cell.cpp:613
 #6  0x00007fffc662121b in CS::Plugin::Terrain2::csTerrainCell::GetHeight
 (this=
     0x7fffd560c9e0, pos=...)
     at
 /home/ralphc/src/CS_LATEST/plugins/mesh/terrain/terrain2/cell.cpp:623
 #7  0x00007fffea12bc7c in
 CS::Plugin::csOpcode::csTerrainSegmentCellCollider::csTerrainSegmentCellCollider
 (this=0x7fffffffc140, cell=0x7fffd560c9f8, start=
     ..., end=...)
     at /home/ralphc/src/CS_LATEST/plugins/collide/opcode/segmentcell.h:94
 #8  0x00007fffea12dc94 in
 CS::Plugin::csOpcode::csTerrainCollider::CollideSegment
 (this=0x7fffd5775b18, cell=0x7fffd560c9f8, start=..., end=...,
 hitPoint=...)
     at
 /home/ralphc/src/CS_LATEST/plugins/collide/opcode/terraincollider.cpp:218
 #9  0x00007fffc6620db6 in
 CS::Plugin::Terrain2::csTerrainCell::CollideSegment (
     this=0x7fffd560c9e0, start=..., end=..., hitPoint=...)
     at
 /home/ralphc/src/CS_LATEST/plugins/mesh/terrain/terrain2/cell.cpp:557
 #10 0x00007fffc66254c6 in
 CS::Plugin::Terrain2::csTerrainSystem::CollideSegment
     (this=0x7fffd5767618, start=..., end=..., hitPoint=...,
 hitMaterial=0x0)
     at
 /home/ralphc/src/CS_LATEST/plugins/mesh/terrain/terrain2/terrainsystem.cpp:278
 #11 0x00007fffc6626cbb in
 CS::Plugin::Terrain2::csTerrainSystem::HitBeamOutline
     (this=0x7fffd5767618, start=..., end=..., isect=...,
 pr=0x7fffffffc54c,
     material=0x0)
     at
 /home/ralphc/src/CS_LATEST/plugins/mesh/terrain/terrain2/terrainsystem.cpp:616
 #12 0x00007fffc6626e59 in
 CS::Plugin::Terrain2::csTerrainSystem::HitBeamOutline
     (this=0x7fffd5767618, start=..., end=..., isect=...,
 pr=0x7fffffffc54c)
     at
 /home/ralphc/src/CS_LATEST/plugins/mesh/terrain/terrain2/terrainsystem.cpp:649
 #13 0x00007fffebdd6f4e in
 CS::Plugin::Engine::csMeshWrapper::HitBeamOutline (
     this=0x7fffca5a8760, start=..., end=...)
     at /home/ralphc/src/CS_LATEST/plugins/engine/3d/meshobj.cpp:931
 #14 0x00007fffebdd728a in CS::Plugin::Engine::csMeshWrapper::HitBeam
 (this=
     0x7fffca5a8760, start=..., end=..., do_material=false, bf=false)
     at /home/ralphc/src/CS_LATEST/plugins/engine/3d/meshobj.cpp:979
 #15 0x00007fffebdea00c in
 CS::Plugin::Engine::csMeshGenerator::GeneratePositions
 (this=0x7fffca5a9f68, cidx=1799, cell=..., block=0x7fffd842a900)
     at
 /home/ralphc/src/CS_LATEST/plugins/engine/3d/meshgen/meshgen.cpp:915
 #16 0x00007fffebdea810 in
 CS::Plugin::Engine::csMeshGenerator::AllocateBlock (
     this=0x7fffca5a9f68, cam=0x7fffa4c4b0e0, cidx=1799, cell=...)
     at
 /home/ralphc/src/CS_LATEST/plugins/engine/3d/meshgen/meshgen.cpp:1016
 #17 0x00007fffebdeb5b6 in
 CS::Plugin::Engine::csMeshGenerator::UpdateForPosition
 (this=0x7fffca5a9f68, cam=0x7fffa4c4b0e0, pos=...)
     at
 /home/ralphc/src/CS_LATEST/plugins/engine/3d/meshgen/meshgen.cpp:1214
 #18 0x00007fffebd5733c in csSector::PrepareDraw (this=0x7fff7053cc10,
 rview=
     0x7fffdfac68a8)
     at /home/ralphc/src/CS_LATEST/plugins/engine/3d/sector.cpp:933
 #19 0x00007fffdfc16494 in
 CS::Plugin::RMUnshadowed::StandardContextSetup<CS::RenderManager::RenderTree<CS::RenderManager::RenderTreeLightingTraits>,
 CS::RenderManager::MultipleRenderLayer>::operator() (this=0x7fffffffd730,
 context=...,
     portalSetupData=..., recursePortals=true)
     at
 /home/ralphc/src/CS_LATEST/plugins/rendermanager/unshadowed/unshadowed.cpp:84
 #20 0x00007fffdfc26bad in
 CS::RenderManager::StandardPortalSetup<CS::RenderManager::RenderTree<CS::RenderManager::RenderTreeLightingTraits>,
 CS::Plugin::RMUnshadowed::StandardContextSetup<CS::RenderManager::RenderTree<CS::RenderManager::RenderTreeLightingTraits>,
 CS::RenderManager::MultipleRenderLayer> >::SetupSimplePortal
 (this=0x7fffffffd020, context=..., setupData=..., portal=0x7fffc7473468,
     sector=0x7fff7053cc70, portalVerts2d=0x7fff217597c0, portalVerts3d=
     0x7fff26492eb0, count=4, screenW=1280, screenH=720, holder=...)
     at ./include/csplugincommon/rendermanager/portalsetup.h:461
 #21 0x00007fffdfc1e6a9 in
 CS::RenderManager::StandardPortalSetup<CS::RenderManager::RenderTree<CS::RenderManager::RenderTreeLightingTraits>,
 CS::Plugin::RMUnshadowed::StandardContextSetup<CS::RenderManager::RenderTree<CS::RenderManager::RenderTreeLightingTraits>,
 CS::RenderManager::MultipleRenderLayer> >::operator() (
     this=0x7fffffffd020, context=..., setupData=...)
     at ./include/csplugincommon/rendermanager/portalsetup.h:373
 #22 0x00007fffdfc16576 in
 CS::Plugin::RMUnshadowed::StandardContextSetup<CS::RenderManager::RenderTree<CS::RenderManager::RenderTreeLightingTraits>,
 CS::RenderManager::MultipleRenderLayer>::operator() (this=0x7fffffffd730,
 context=...,
     portalSetupData=..., recursePortals=true)
     at
 /home/ralphc/src/CS_LATEST/plugins/rendermanager/unshadowed/unshadowed.cpp:100
 #23 0x00007fffdfc26bad in
 CS::RenderManager::StandardPortalSetup<CS::RenderManager::RenderTree<CS::RenderManager::RenderTreeLightingTraits>,
 CS::Plugin::RMUnshadowed::StandardContextSetup<CS::RenderManager::RenderTree<CS::RenderManager::RenderTreeLightingTraits>,
 CS::RenderManager::MultipleRenderLayer> >::SetupSimplePortal
 (this=0x7fffffffd480, context=..., setupData=..., portal=0x7fffb48ea390,
     sector=0x7fffc7470248, portalVerts2d=0x7fff217229f8, portalVerts3d=
     0x7fff216dfd00, count=4, screenW=1280, screenH=720, holder=...)
     at ./include/csplugincommon/rendermanager/portalsetup.h:461
 #24 0x00007fffdfc1e6a9 in
 CS::RenderManager::StandardPortalSetup<CS::RenderManager::RenderTree<CS::RenderManager::RenderTreeLightingTraits>,
 CS::Plugin::RMUnshadowed::StandardContextSetup<CS::RenderManager::RenderTree<CS::RenderManager::RenderTreeLightingTraits>,
 CS::RenderManager::MultipleRenderLayer> >::operator() (
     this=0x7fffffffd480, context=..., setupData=...)
     at ./include/csplugincommon/rendermanager/portalsetup.h:373
 #25 0x00007fffdfc16576 in
 CS::Plugin::RMUnshadowed::StandardContextSetup<CS::RenderManager::RenderTree<CS::RenderManager::RenderTreeLightingTraits>,
 CS::RenderManager::MultipleRenderLayer>::operator() (this=0x7fffffffd730,
 context=...,
     portalSetupData=..., recursePortals=true)
     at
 /home/ralphc/src/CS_LATEST/plugins/rendermanager/unshadowed/unshadowed.cpp:100
 #26 0x00007fffdfc10bec in
 CS::Plugin::RMUnshadowed::RMUnshadowed::RenderView (
     this=0x7fffeaedf870, view=0x7fffc9d62ba0, recursePortals=true)
     at
 /home/ralphc/src/CS_LATEST/plugins/rendermanager/unshadowed/unshadowed.cpp:289
 #27 0x00007fffdfc10e64 in
 CS::Plugin::RMUnshadowed::RMUnshadowed::RenderView (
     this=0x7fffeaedf870, view=0x7fffc9d62ba0)
     at
 /home/ralphc/src/CS_LATEST/plugins/rendermanager/unshadowed/unshadowed.cpp:326
 #28 0x00007ffff7926f42 in csView::Draw (this=0x7fffc9d62b88, mesh=0x0)
     at /home/ralphc/src/CS_LATEST/libs/cstool/csview.cpp:187
 #29 0x00000000004eb8a8 in psCamera::Draw (this=0x36ed2e0)
     at src/client/pscamera.cpp:818
 #30 0x0000000000491c4f in psEngine::Process3D (this=0xe47330, ev=...)
     at src/client/psengine.cpp:1022
 #31 0x00000000004773e5 in psEngine::EventHandler3D::HandleEvent (this=
     0x7fffdfab3500, ev=...) at src/client/psengine.h:861
 #32 0x00007ffff7736ec5 in csEventTree::Dispatch (this=0xaf3a70, e=...)
     at /home/ralphc/src/CS_LATEST/libs/csutil/cssubscription.cpp:576
 #33 0x00007ffff7736dab in csEventTree::Notify (this=0xaf3a70)
     at /home/ralphc/src/CS_LATEST/libs/csutil/cssubscription.cpp:546
 #34 0x00007ffff76e8c11 in csEventQueue::Notify (this=0x7ffff751d540,
 name=...)
     at /home/ralphc/src/CS_LATEST/libs/csutil/cseventq.cpp:239
 #35 0x00007ffff76e8d04 in csEventQueue::Process (this=0x7ffff751d540)
     at /home/ralphc/src/CS_LATEST/libs/csutil/cseventq.cpp:255
 #36 0x00007ffff77ea13f in csDefaultRunLoop (r=0x7ffff10bfea0)
     at /home/ralphc/src/CS_LATEST/libs/csutil/generic/runloop.cpp:99
 #37 0x0000000000498813 in main (argc=1, argv=0x7fffffffe008)
     at src/client/psengine.cpp:2127
 }}}

-- 
Ticket URL: <http://www.crystalspace3d.org/trac/CS/ticket/982#comment:3>
CrystalSpace <http://www.crystalspace3d.org/>
Free open-source 3D SDK.
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev